Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Log4j config for the app running on AWS beanstalk

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to implement logging using the log4j in the web app running on tomcat at AWS beanstalk environment. I need to write the logs into catalina.out file situated at "/var/log/tomcat" path.  
Can anyone please let me know how to set the path in log4j.properties. I am actually looking for the value of  the line 3 "log4j.appender.file.File".

log4j.rootLogger=${tomcat.server.log.threshold},file
log4j.appender.file=org.apache.log4j.RollingFileAppender
log4j.appender.file.File=
log4j.appender.file.MaxFileSize=10MB
log4j.appender.file.MaxBackupIndex=10
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ISO8601} %-5p %-4L %C{5} %m%n
log4j.logger.com.ptc=${tomcat.server.log.threshold},file
 
Saloon Keeper
Posts: 23006
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't recommend toing that.

Tomcat is not designed to log to "catalina.out". What you see in the TOMCAT_HOME/logs/catalina.out file is simply a capture of the JVM's stdout and stderr streams. The routing to catalina.out is not done in Tomcat, but in the Tomcat run script. And actually, not all Tomcat executives are set up to redirect that way. It's just the most common setup.

So you could log to catalina.out by setting up log4j to channel to stdout. But it's preferable to log each app to its own logfiles. On Unix-like systems such as Beanstalk, the usual convention would be to log to a file in a directory such as /var/log/myapp, where the "myapp" directory has write access permission for Tomcat. Or, you can log to a file in TOMCAT_HOME/logs, if that works better for you.

One reason for NOT wanting to log apps to catalina.out is that if a production operator needs to provide a copy of an application's log to a developer for troubleshooting they don't have to screen out all the sensitive stuff from the log that doesn't relate to that app.
 
pari Nagda
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you elaborate it "So you could log to catalina.out by setting up log4j to channel to stdout" . I would be interested to know how to do it using log4j.properties file.
 
Tim Holloway
Saloon Keeper
Posts: 23006
156
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pari Nagda wrote:Can you elaborate it "So you could log to catalina.out by setting up log4j to channel to stdout" . I would be interested to know how to do it using log4j.properties file.





I prefer log4j.xml, myself. It's capable of some things that a flat properties file isn't. But this will do.
 
A feeble attempt to tell you about our stuff that makes us money
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic