You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Siamak Sarmady <sa...@gmail.com> on 2007/08/30 17:07:45 UTC

Problem with File appender

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


Re: Problem with File appender

Posted by Siamak Sarmady <sa...@gmail.com>.
Matthew, Thank you very much for your help. The problem is solved.


Matthew Kemp wrote:
> You still need to attach the appender to a logger. Try adding this line to
> you log4j properties file:
> 
> log4j.rootLogger=info, file


---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org


Re: Problem with File appender

Posted by Matthew Kemp <ma...@gmail.com>.
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 <sa...@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
>
>