Solved

Log4j set log folder to program argument args[5]

Posted on 2011-03-07
3
289 Views
Last Modified: 2012-05-11
Hello,

I'm required to create a jar of my application, instead of the batch file previously implemented.  The code I have written is now being integrated into a new environment where arguments and executable (i.e. jar) are defined in an xml file.

In the previous setup the log file was a VM argument, the log4j.properties file contained:

log4j.appender.rollingFile.File = ${logDir_var}/adapter.log

Now that's its inserted as a program argument I'm unsure how to set this.
0
Comment
Question by:AndyC1000
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 250 total points
ID: 35065702
0
 
LVL 92

Assisted Solution

by:objects
objects earned 250 total points
ID: 35065716
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 35068020
>>log4j.appender.rollingFile.File = ${logDir_var}/adapter.log

Just make sure that the env var is passed when you execute the jar - that's all you need to do:

java -DlogDir_var=foo -jar bar.jar

Open in new window

0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
going to wrong jsp page 2 69
wild fly 8 startup error 2 79
What is the use of Forwarding Class in java 1 53
Is there a Google Voice API? 9 70
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question