This discussion is archived
12 Replies Latest reply: Oct 4, 2012 5:31 AM by sabre150 RSS

java log4j not initialized even in src path

965587 Newbie
Currently Being Moderated
Hi all,

We are working with struts application in IBM Websphere server 7.0 ,we use log4j.properties file to log statements and the jar we are using is log4j-1.2.8 jar. To make this log4j work we placed the log4j.properties in src after deployment which comes under WEB-INF/classes folder and the jar file is referenced in the classpath file there are other jar files also like common-logging.jar etc.
This application works fine in local setup only this issue is in linux servers.
When we do search for initializing log4j only thing they are suggesting in classpath and we also have referenced in classpath the log4j other than that we couldnt find any other suggestion , Could anyone suggest a solution for this issue

Thanks in advance
  • 1. Re: java log4j not initialized even in src path
    gimbal2 Guru
    Currently Being Moderated
    yep, needs to be on the classpath just like a normal .class file. There is nothing more to it other than properly formatting the file, so I would rather rethink your expectations. What do you mean by that there is an issue. What is not working? No log files appear? Are you sure you are looking in the right spot?
  • 2. Re: java log4j not initialized even in src path
    965587 Newbie
    Currently Being Moderated
    The issue is that the logger statements are not getting printed. Yes we are looking in right spot that is the place where logs which is getting updated when we access the application.
  • 3. Re: java log4j not initialized even in src path
    gimbal2 Guru
    Currently Being Moderated
    I would recheck the appenders, filters and categories then. Also check the actual deployed binary to be sure the properties file is in there of course, it might just be a question of a deployment mistake.
  • 4. Re: java log4j not initialized even in src path
    965587 Newbie
    Currently Being Moderated
    Hi thanks for your reply. i could give you the log.properties file
    log4j.rootLogger=DEBUG,A1
    log4j.appender.A1=org.apache.log4j.ConsoleAppender
    log4j.appender.A1.layout=org.apache.log4j.TTCCLayout
    log4j.appender.A1.layout.DateFormat=ISO8601

    #log4j.rootLogger=DEBUG, A1, A2
    #log4j.appender.A1.threshold=DEBUG
    #log4j.appender.A1.layout=org.apache.log4j.PatternLayout
    #log4j.appender.A1.layout.ConversionPattern=[%t] %C - %m
    #

    # Tivoli ALert

    #log4j.appender.A2=org.apache.log4j.FileAppender
    #log4j.appender.A2.threshold=DEBUG,FATAL,ERROR,INFO
    #log4j.appender.A2.File=/apps/logs/ws70/finance/CBS01/CBS01.log
    #log4j.appender.A2.layout=org.apache.log4j.PatternLayout
    #log4j.appender.A2.layout.ConversionPattern=%d{MMM dd HH:mm:ss} %m%n


    #For debugging validator configuration
    log4j.logger.org.apache.commons.validator=DEBUG
    log4j.logger.org.apache.struts.validator=DEBUG

    From the suggestion deployed binaries ,what i am getting is that the WAR is the end product of binaries after deployment i could see the log4j.properties
    Our concern is this EAR works in local by giving the logger statements it is not working in linux servers.
  • 5. Re: java log4j not initialized even in src path
    Tolls Journeyer
    Currently Being Moderated
    I see a console logger there, but I don't see a file logger?
    Could be my eyes of course...
  • 6. Re: java log4j not initialized even in src path
    965587 Newbie
    Currently Being Moderated
    yes we have used console logger only so the logs will be printed in the SystemOut.log file which is the default log file.
  • 7. Re: java log4j not initialized even in src path
    aksarben Journeyer
    Currently Being Moderated
    What do you mean by "SystemOut.log file which is the default log file"? If you don't have a log4j file appender, then log4j will not write to a log file. Thus, this is not a log4j issue. Rather, it is an issue with how SystemOut.log gets output.

    Are you redirecting stdout? If so, you should be looking at where that happens & where that redirected output is going. At the risk of repeating myself, if you're expecting log4j to generate a log file without a file appender, you're barking up the wrong tree.
  • 8. Re: java log4j not initialized even in src path
    965587 Newbie
    Currently Being Moderated
    ok as you say if the fileAppender is not given the logs will not be written,the same applciation is printing logs with same property file in WAS 5.1 version,how it could be possible.
  • 9. Re: java log4j not initialized even in src path
    sabre150 Expert
    Currently Being Moderated
    Maybe 5.1 provided a default appender ?

    You can spend the next 5 years arguing about this but you are only going to resolve it by seeing what happens when you supply an appender.
  • 10. Re: java log4j not initialized even in src path
    gimbal2 Guru
    Currently Being Moderated
    962584 wrote:
    ok as you say if the fileAppender is not given the logs will not be written,the same applciation is printing logs with same property file in WAS 5.1 version,how it could be possible.
    Different software, different defaults, different behavior. Its all one big read the manuals. (Plural)
  • 11. Re: java log4j not initialized even in src path
    965587 Newbie
    Currently Being Moderated
    Thanks for all replies. Here i changed the log4j.properties with fileAppender
    log4j.appender.SalesTaxAppender=org.apache.log4j.RollingFileAppender
    log4j.appender.SalesTaxAppender.MaxFileSize=4000KB
    log4j.appender.SalesTaxAppender.MaxBackupIndex=5
    log4j.appender.SalesTaxAppender.layout=org.apache.log4j.PatternLayout
    log4j.appender.SalesTaxAppender.layout.ConversionPattern=[%d] %-5p %c - %m%n
    log4j.appender.SalesTaxAppender.File=File.log

    Eventhough aftr deployment i couldnt see this file is created, so from my understanding the log4j is not getting initialised where i am going wrong if it is the case what steps can i take,please suggest.
  • 12. Re: java log4j not initialized even in src path
    sabre150 Expert
    Currently Being Moderated
    So where do you expect the file File.log to be written? Have you searched the file system for this file?

    P.S. Not a very informative name for the log file is it!

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points