• 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
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

multiple executable jars use single log4j.properties file to create separate log files.

 
Ranch Hand
Posts: 649
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone know how can I have a single log4j.properties file which will be referenced by multiple executable jars and create a separate log file for each jar.
I am having 3 executable jar files, for which I am maintaining three log4j.properties file separately. I am running the jars using VM argument -Dlog4j.configuration="file:/C:/Users/puspender.tanwar/Desktop/someDirectory/log4j.properties"
This is my log4j.properties file:

Is there any way I can tell Log4j to log on the basis of jar file I am using.
 
Puspender Tanwar
Ranch Hand
Posts: 649
2
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured out the solution. In such requirement, we have to use appenders. Separate appenders for each project. Here is my log4j.properties file now:

But while starting the application(any), I get warning as:

I know this is coming because their is not root logger handled. I tried that also

The root logger only prints on ERROR, but it is logging as INFO do.

I can I overcome this. Actually I don't want a root logger.
 
All of the following truths are shameless lies. But what about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic