[logback-user] Multiple files and other issues
Ceki Gulcu
ceki at qos.ch
Fri Mar 6 09:43:12 CET 2009
Marco,
Let's start one problem at a time. Here is a simple config file. Try using it
and see how it goes. Will build up from there.
<configuration debug="true">
<appender name="ROOT" class="ch.qos.logback.core.FileAppender" >
<file>traces/MyApp</file>
<append>false</append>
<!-- admit only ERROR messages in this appender -->
<!--
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>error</level>
</filter>
-->
<layout>
<pattern>%d{yyyy-MM-dd HH:mm:ss},%p,%c,%F,%C{1} %m%n</pattern>
</layout>
</appender>
<root level="DEBUG">
<appender-ref ref="ROOT"/>
</root>
</configuration>
If you can run the above correctly, we'll add more functionality one step at a
time.
Marco Bresciani wrote:
> Hello all,
> I've just began using Logback and it is sooo good! :-) I'm still a newbie so
> for my attempts I'm using the online wizard and then trying to adapting and
> customizing it by hand, when needed, in order to find the correct
> configuration for my needs (many packages, many classes, different needs and
> logs levels, ...).
>
> I've reached a sort of nirvana by simply using the wizard without any
> customization and no other "strange things". I've read the manual again and
> again but I'm still having some problems, anyway. :-( (I'm going to feel the
> dark side of the newbies...) Could anyone please help? (At the end of the
> email, an example logback.xml I've made with the wizard)
>
> 1. I've tried to use HTML file format, even with a very simple/basic
> configuration, but no output has been produced;
>
> 2. I'm getting crazy trying to have a customizable/variable file name. If two
> instances of my application run; I need to have two logs. I.e.: first instance
> being ran at 10.30, second instance being ran at 11.04 then the log files
> should be something like logs/MyApp at 10.30.45.log and logs/MyApp at 11.04.32.log.
> I really need this and I'm getting crazy... Please help!
>
> 3. I'm still having a bit of troubles in splitting the logs of specific parts
> or packages or sub-applications, through different log files. I.e.:
> logs/MyApp at 10.30.45.log and logs/MyApp_SpecialPackage at 10.30.46.log and so on.
> Is the XML made by the wizard correct?
>
>
>
> Really really thanks in advance for any help anyone could give me,
>
>
> Marco
>
>
> This is an example of what I've done... many attempts...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <configuration>
> <appender class="ch.qos.logback.core.FileAppender"
> name="my.special.package.logger.thingFileAppender">
> <file>traces/SpecialPackage</file>
> <append>true</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>error</level>
> </filter>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss},%p,%c,%t,%C{1},%M %m%n</pattern>
> </layout>
> </appender>
> <appender class="ch.qos.logback.core.FileAppender" name="RootFileAppender">
> <file>traces/MyApp</file>
> <append>false</append>
> <filter class="ch.qos.logback.classic.filter.ThresholdFilter">
> <level>error</level>
> </filter>
> <layout class="ch.qos.logback.classic.PatternLayout">
> <pattern>%d{yyyy-MM-dd HH:mm:ss},%p,%c,%F,%C{1} %m%n</pattern>
> </layout>
> </appender>
> <logger additivity="false" name="my.special.package.logger.thing">
> <level value="error"/>
> <appender-ref ref="my.special.package.logger.thingFileAppender"/>
> </logger>
> <root>
> <level value="debug"/>
> <appender-ref ref="RootFileAppender"/>
> </root>
> </configuration>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Logback-user mailing list
> Logback-user at qos.ch
> http://qos.ch/mailman/listinfo/logback-user
--
Ceki Gülcü
Logback: The reliable, generic, fast and flexible logging framework for Java.
http://logback.qos.ch
More information about the Logback-user
mailing list