Win a copy of Emmy in the Key of Code this week in the General Computing 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
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

log4j environment setup

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can any one please help me how to get environment variables from tomcat's server.xml to apache logging file?

For Ex:

I have declared the environment name in tomcat's server.xml file like below:

<GlobalNamingResources>
<Environment name="logFiles" value="C:\Data\"
type="java.lang.Integer" override="false"/>
</GlobalNamingResources>


Now I want to access the variable logFiles from log4j file..

My Log4j File as below

<param name="append" value="true" />
<param name="File" value="${logFiles}/log/Project.log" /> ====> its not working...


I dont want to use catalina.home and java_opts setup.. I want to access the custom variables.
 
Ranch Hand
Posts: 530
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that would be impossible, because log4j configuration file is parsed by Log4j (not Tomcat), and log4j does not know (or care) about Tomcat's config file.
 
Saloon Keeper
Posts: 21240
137
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Context Resources are published to the Tomcat applications via JNDI. If your webapp(s) contain customized log4j configuration code, that code can do a JNDI lookup and use it as part of the controlling information.

Note that Tomcat itself does not use log4j for its own logging, it uses the Java util.logging package (JULI), unless you do a custom Tomcat build for log4j. Each webapp is totally responsible for its own logging, so whatever log package you use for a webapp is that webapp's own choice.

Although most of the Tomcat documentation is pretty good, the one place I found it lacking was that it failed to indicate these things clearly.
 
Booma Devi
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your reply.. I have solved the problem by specifying the system properties in ServletContextListener.
 
permaculture is largely about replacing oil with people. And one tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!