[logback-user] custom logger / appender / layout

Daniel Rossi spam at electroteque.org
Tue Oct 23 16:55:15 CEST 2007

Hi there I have a custom spring app I need to setup an access log  
for. I'm needing it in W3C format for reporting purposes. I'm porting  
it to logback from log4j because the server the application is in is  
now using it. How is it possible to create a custom logger with  
custom log level methods, a custom level class with levels higher  
than FATAL so it doesnt get mixed up with the root logger. Im also  
needing to create it all programatically so setup the logger when  
requested because i need to produce a logger for each context path in  
the spring app so i get a different log file for each context. Issue  
ive experienced so far porting my code is that the layout,  
rollingpolicy and appender all need contexts set to it or else it  
complains about no context set ? I'm also needing to work out how it  
would be possible to create a custom even / layout / pattern  
convertor to obtain particular statistical details from the server  
similar to the implementations for tomcat and jetty though its a  
video server and not sure if its running in a servlet as such.

Ive worked out so far there is possibilities to add fields set in the  
MDC to the file header aswell as in the pattern string for the file  

As of now no log file is being set.

Here is the code so far.

MDC.put("x-event", "stop");
MDC.put("x-category", "stream");

logStats = (Logger)LoggerFactory.getLogger(loggerName);
if (null == logStats.getAppender(appenderName))
			layout = new PatternLayout();
			layout.setPattern("%X{x-event} %X{x-category} - %msg%n");
			layout.setFileHeader("x-event \t x-category");

			appender = new RollingFileAppender();
			policy = new TimeBasedRollingPolicy();

     		policy.setFileNamePattern(path + logFilePattern);



Currently I have to call


In my log4j class it was


which present the stop level inside it, but cant find and  
implementation to subclass as yet.

Let me know thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://qos.ch/pipermail/logback-user/attachments/20071024/140c0c65/attachment.htm 

More information about the Logback-user mailing list