Reputation: 24316
I currently am using the SocketAppender
in Log4J and have run into some issues with passing data over to a remote host, specifically around losing LocationInfo
(class name, line number, etc). What I have done is the following:
import org.apache.commons.logging.impl.Log4JLogger;
public class MyLogger extends Log4JLogger
{
...
public void debug(Object message)
{
String extra = "Extra!";
super.debug(message + extra);
}
...
}
At runtime how can I change the following code to grab MyLogger
instead of Log4JLogger
?
private static Log logger = LogFactory.getLog(Test.class);
Upvotes: 0
Views: 461
Reputation: 7807
You don't have to extends Logger but implement your own Appender or extend the base Log4J Appender you need. For example you can extend AppenderSkeleton.
I cannot imagine exactly why do you need it. Another possibility could be use Log4J Mapped Diagnostic Context.
Upvotes: 1