You say this is running in Eclipse? Maybe a plugin is performing configuration
and looking up another file? Log4j uses log4j.xml in preference to
log4j.properties, so the automatic configuration process would use your
log4j.xml file even if a log4j.properties existed in the classpath. Look for
other configuration files that might be taking precedence, like another
log4j.xml file placed earlier in the classpath.
Also, I would suggest that you perform a test on the command line to verify that
your config does what you expect. When you verify that what you have is
correct, then test it in more complex environments like Eclipse.
Jake
Quoting "Zadoo, Vishal (Accenture)" <[EMAIL PROTECTED]>:
> Hi ,
> Thanks for the suggestion.
> I have changed to log4j.xml . However, when i run my project in eclipse for
> the same, it seems it is not reading from the xml file.. All log messages are
> going to the console.. While they should go to the file..
> The log messages were going in the file when i was using log4j.properties..
>
>
> Following is the log4j.xml. Any ideas why it is behaving like this?
>
> <?xml version="1.0" encoding="UTF-8" ?>
> <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
> <log4j:configuration>
>
> <appender name="trace" class="org.apache.log4j.FileAppender">
> <param name="file" value="/trace.log" />
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern"
> value="[%d{ISO8601}] %-5p %c %m %n" />
> </layout>
> <filter class="org.apache.log4j.varia.LevelRangeFilter">
> <param name="LevelMin" value="TRACE"/>
> <param name="LevelMax" value="DEBUG"/>
> </filter>
> </appender>
>
> <appender name="error" class="org.apache.log4j.FileAppender">
> <param name="file" value="/error.log" />
> <layout class="org.apache.log4j.PatternLayout">
> <param name="ConversionPattern"
> value="[%d{ISO8601}] %-5p %c %m %n" />
> </layout>
> <filter class="org.apache.log4j.varia.LevelRangeFilter">
> <param name="LevelMin" value="INFO"/>
> <param name="LevelMax" value="FATAL"/>
> </filter>
> </appender>
>
> <root>
> <level value="all" />
> <appender-ref ref="trace"/>
> <appender-ref ref="error"/>
> </root>
>
> </log4j:configuration>
>
> -----Ursprüngliche Nachricht-----
> Von: Jacob Kjome [mailto:[EMAIL PROTECTED]
> Gesendet: Freitag, 8. Dezember 2006 17:39
> An: Log4J Developers List
> Betreff: Re: Problem while logging different levels in different log files
>
>
>
> Search the list for recent discussions about using filters. BTW, you'll need
> to change to an XML config format to use filters.
>
> Not specifically applicable to this situation, at times you can use
> additivity if you want to control which loggers/levels log to particular
> appenders at the logger level. Basically, setting additivity to "false"
> disables the normal logger hierarchy inheritance. Again, doesn't apply here,
> but I thought I'd mention it.
>
> Jake
>
> Quoting "Zadoo, Vishal (Accenture)" <[EMAIL PROTECTED]>:
>
> >
> >
> >
> >
> > Hi,
> > I need to log different levels of log in different log files
> > exclusively. I am using the following log4j.properties: # Set root
> > logger level to DEBUG and its only appender to A1.
> >
> > log4j.rootLogger=INFO,A1,A2
> >
> >
> >
> > # A1 is set to trace.log.
> >
> > log4j.appender.A1=org.apache.log4j.RollingFileAppender
> >
> > log4j.appender.A1.File=trace.log
> >
> > log4j.appender.A1.Threshold=INFO
> >
> > # A1 uses PatternLayout.
> >
> > log4j.appender.A1.layout=org.apache.log4j.PatternLayout
> >
> > log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
> >
> >
> >
> > # A2 is set to be a fileAppender named error.log
> >
> > log4j.appender.A2=org.apache.log4j.RollingFileAppender
> >
> > log4j.appender.A2.File=error.log
> >
> > log4j.appender.A2.Threshold=ERROR
> >
> > # A2 uses PatternLayout.
> >
> > log4j.appender.A2.layout=org.apache.log4j.PatternLayout
> >
> > log4j.appender.A2.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
> >
> > Currently im facing the problem that my error level messages are going
> > to a error.log , but my trace level message file(trace.log) has both
> > trace and error messages. It shud contain only trace level messages.
> > Has anybody tried something like this before?
> >
> >
> > Vishal
> >
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]