• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Log file not being created or appended to with log4j

 
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the log4j.properties file below which is being used when I deploy my application on Sun Java Web Server 7. The log file (../logs/myapp.log) is never created or appended to, can anyone suggest why?

log4j.rootCategory=WARN,FILE
log4j.logger.com.mycom.myapp=TRACE
log4j.appender.FILE=org.apache.log4j.RollingFileAppender
log4j.appender.FILE.File=../logs/myapp.log
log4j.appender.FILE.MaxFileSize=1000KB
log4j.appender.FILE.MaxBackupIndex=1
log4j.appender.FILE.layout=org.apache.log4j.PatternLayout
log4j.appender.FILE.layout.ConversionPattern=[%p %d{DATE} %t %C{1}] %m%n


Thanks in advance for any help!


--James
 
Sheriff
Posts: 28413
102
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Assuming that your statement that the properties file is being used is a true statement, then the answer to your question is quite likely: Your log file is being created and used. You are making an incorrect assumption about what directory that path is relative to.
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, you bring up a good point -- it may be that the properties file is never being read. It lives in WEB-INF/classes/log4j.properties in my WAR file. I have enabled all debugging in my web server and there are no log messages indicating that there is a problem with log4j when I start my application. I have run a find command looking for the log file I specify in the log4j.properties and it is never found after the application is started, which leads me to believe that the log4j.properties is never read/used. I don't know of a way to verify that the properties file is being read/used. Is there a way to do so?

--James
 
James Adams
Ranch Hand
Posts: 188
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure of what the problem was but now everything is working as expected. One thing I did which may have helped was that I modified the logging properties of my web server using the following wadm command:

wadm set-log-prop --user=admin --host=localhost --port=8989 --config=ja-z1 log-virtual-server-name=true log-stdout=true log-stderr=true log-level=fine


--James
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am just mentioning something that I consider as best practice , might be helpful but might not be what exactly you are looking for.

For any application that I create , I have a config directory which stores all the configuration files for my application and I pass it to the application as parameter like ; I can pass it to my initialization servlet as servlet config parameter.

In the init method of my initialization servlet (or any other appropriate place) I read the config dir path and append log4j.properties to that.It makes the full path of the log4j.properties and use it in PropertyConfigurator.

Again for specifying log file , I prefer specifying the full path of the file from the root of the filesystem.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic