http://java.sun.com/j2se/1.4.2/docs/api/java/lang/System.html#setProperty(java.lang.String,%20java.lang.String)

Jake

On Mon, 8 Oct 2007 12:13:49 -0400
 "Ashish Kulkarni" <[EMAIL PROTECTED]> wrote:
Hi
I was also thinking along to way,
but how did you set up System property in java for example if in my
log4j.xml file i set
<param name="File"
value="${mywebapp}\\log4jXmlFilter.log" />
and in the Servlet Context listner, i will get the path to mywebapp
but how do i set it in java.. is there some thing like System.setPath or
some method to do so?
which is the right method.
Also will this cause issue if i have 2 -3 different
applications setting the same path, will it work
Is this path for same application or all the applications


Ashish


On 10/5/07, Jacob Kjome <[EMAIL PROTECTED]> wrote:


Of course it is possible to set -D System properites using Weblogic.  You
just
have to have access to the startup script, which is not guaranteed.

In any case, setting a system property does not fully solve the issue
unless
there is only a single app running on the server.  When there is more than
one
app, setting a single system property to point to a log file path assumes
that
you want all apps using the system property to log to the same
directory.  The
original request mentioned "I would prefer the log file to be under the
same
folder application is installed".

In fact, I wrote a servlet context listener that does exactly this.  It
dynamically determines the path of the current webapp and sets a system
property according to a naming convention making it possible to reference
this
system property in your webapp.  I know it works under Tomcat, but I can't
guarantee it will work under other appservers because I haven't tested
under
other appservers.  See....

http://wiki.apache.org/logging-log4j/AppContainerLogging

specifically, read the javadoc for InitContextListener...


http://svn.apache.org/repos/asf/logging/sandbox/log4j/log4j_sandbox/tags/LOG4J_SANDBOX_ALPHA3/src/java/org/apache/log4j/servlet/InitContextListener.java


Jake

On Thu, 4 Oct 2007 16:07:25 -0500
  "James A. N. Stauffer" <[EMAIL PROTECTED]> wrote:
> I use Tomcat and I can set system properties.  I would be very
> surprise if you can't set system properties on WebLogic.  This might
> not work if you aren't given the rights to set system properties.
>
> On 10/4/07, Ashish Kulkarni <[EMAIL PROTECTED]> wrote:
>> Hi
>> But will this work in web application also, for example i am installing
>> software on web logic, or websphere, will this work
>>
>> Ashis
>> On 10/4/07, James A. N. Stauffer <[EMAIL PROTECTED]> wrote:
>> >
>> > If you set a system property it can be used in your log4j.xml.
>> > <param name="File" value="${log4jXmlFilter}"/>
>> >
>> > You your machine run java with -Dlog4jXmlFilter=C:/Documents and
>> > Settings/Kulkara/My
>> >
>> >

>>Documents/ashish/code/workspace5.1M/version6300build12-00/log4jXmlFilter.log
>> >
>> > On 10/4/07, Ashish Kulkarni <[EMAIL PROTECTED]> wrote:
>> > > Hi
>> > > How do we set the log file location dyanamically in web
application,
>> > > Currently i am using log4j.xml file with following definiation,
this
>> > file is
>> > > under WEB-INF file
>> > > <appender name="A2" class="
org.apache.log4j.DailyRollingFileAppender">
>> > > <param name="File"
>> > > value="C:\\Documents and Settings\\Kulkara\\My
>> > >
>> >

>>Documents\\ashish\\code\\workspace5.1M\\version6300build12-00\\log4jXmlFilter.log"
>> > > />
>> > > ... </appender>
>> > > and in load the this xml file in Servlet using
>> > > String fileName = config.getInitParameter(log4j.xml);
>> > > ServletContext oCtx = config.getServletContext();
>> > > URL path = oCtx.getResource (fileName);
>> > > DOMConfigurator.configure(path);
>> > >
>> > > But if i have to install this on unix, i have to change the path,
also
>> > the
>> > > server on which i will install this may not have the folder, so i
will
>> > have
>> > > to recreate a war file
>> > > So is there a dynamic way of telling log4j the location and name of
log
>> > > file? which can work on any system.
>> > > i would prefer the log file to be under the same folder application
is
>> > > installed
>> > >
>> > > Ashish
>> > >
>> >
>> >
>> > --
>> > James A. N. Stauffer        http://www.geocities.com/stauffer_james/
>> > Are you good? Take the test at http://www.livingwaters.com/good/
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [EMAIL PROTECTED]
>> > For additional commands, e-mail: [EMAIL PROTECTED]
>> >
>> >
>>
>
>
> --
> James A. N. Stauffer        http://www.geocities.com/stauffer_james/
> Are you good? Take the test at http://www.livingwaters.com/good/
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to