• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

log4j environment setup

 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 27764
196
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
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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.. I have solved the problem by specifying the system properties in ServletContextListener.
 
Does this tiny ad smell okay to you?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic