logging-log4j-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Kemp" <mattk...@gmail.com>
Subject Re: Problem with File appender
Date Thu, 30 Aug 2007 15:14:04 GMT
You still need to attach the appender to a logger. Try adding this line to
you log4j properties file:

log4j.rootLogger=info, file

On 8/30/07, Siamak Sarmady <sarmadys@gmail.com> wrote:
>
> Hello,
>
> I have a simple log4j program.
>
> When I use the "stdout log messages" section of my log4j.properties,
> log4j works well. But when I uncomment "file appender" section I get the
> following errors:
>
> log4j:WARN No appenders could be found for logger (LogClass).
> log4j:WARN Please initialize the log4j system properly.
>
> I am confused because I used to see these errors when the
> log4j.properties was not on Classpath. But here it is obviously working
> with the stdout.
>
> Could someone please kindly help?
>
> Regards,
> Mac
>
>
>
> ### file appender ###
> log4j.appender.file=org.apache.log4j.RollingFileAppender
> log4j.appender.file.maxFileSize=100KB
> log4j.appender.file.maxBackupIndex=5
> log4j.appender.file.File=test.log
> log4j.appender.file.threshold=info
> log4j.appender.file.layout=org.apache.log4j.PatternLayout
> log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L
> -%m%n
>
> ### stdout log messages ###
> #log4j.appender.stdout=org.apache.log4j.ConsoleAppender
> #log4j.appender.stdout.Target=System.out
> #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
> #log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p
> %c{1}:%L - %m%n
> #log4j.rootLogger=warn, stdout
>
>
>
>
>
> public class LogClass {
>      private static org.apache.log4j.Logger log = Logger
>             .getLogger(LogClass.class);
>
>      public static void main(String[] args) {
>                         log.info("Info");
>      }
> }
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
> For additional commands, e-mail: log4j-user-help@logging.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message