Created
April 6, 2014 18:49
-
-
Save anidotnet/10010031 to your computer and use it in GitHub Desktop.
Log4j2 Log Delegate Implementation for Vert.x
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dizitart.logging; | |
import org.vertx.java.core.logging.impl.LogDelegate; | |
import org.apache.logging.log4j.LogManager; | |
import org.apache.logging.log4j.Logger; | |
/** | |
* A {@link LogDelegate} which delegates to Apache Log4j 2.x | |
* | |
* @author <a href="anidotnet@gmail.com">anidotnet@gmail.com</a> | |
*/ | |
public class Log4j2LogDelegate implements LogDelegate { | |
private final Logger logger; | |
Log4j2LogDelegate(final String name) { | |
logger = LogManager.getLogger(name); | |
} | |
public boolean isInfoEnabled() { | |
return logger.isInfoEnabled(); | |
} | |
public boolean isDebugEnabled() { | |
return logger.isDebugEnabled(); | |
} | |
public boolean isTraceEnabled() { | |
return logger.isTraceEnabled(); | |
} | |
public void fatal(final Object message) { | |
logger.fatal(message); | |
} | |
public void fatal(final Object message, final Throwable t) { | |
logger.fatal(message, t); | |
} | |
public void error(final Object message) { | |
logger.error(message); | |
} | |
public void error(final Object message, final Throwable t) { | |
logger.error(message, t); | |
} | |
public void warn(final Object message) { | |
logger.warn(message); | |
} | |
public void warn(final Object message, final Throwable t) { | |
logger.warn(message, t); | |
} | |
public void info(final Object message) { | |
logger.info(message); | |
} | |
public void info(final Object message, final Throwable t) { | |
logger.info(message, t); | |
} | |
public void debug(final Object message) { | |
logger.debug(message); | |
} | |
public void debug(final Object message, final Throwable t) { | |
logger.debug(message, t); | |
} | |
public void trace(final Object message) { | |
logger.trace(message); | |
} | |
public void trace(final Object message, final Throwable t) { | |
logger.trace(message, t); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.dizitart.logging; | |
import org.vertx.java.core.logging.impl.LogDelegate; | |
import org.vertx.java.core.logging.impl.LogDelegateFactory; | |
/** | |
* A {@link LogDelegateFactory} which creates {@link Log4j2LogDelegate} instances. | |
* | |
* @author <a href="anidotnet@gmail.com">anidotnet@gmail.com</a> | |
* | |
* | |
*/ | |
public class Log4j2LogDelegateFactory implements LogDelegateFactory { | |
@Override | |
public LogDelegate createDelegate(final String name) { | |
return new Log4j2LogDelegate(name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment