Keeping everything same, I just changed the way I was providing the path to 
log4j.properties file. 

An example with a made-up directory path.

Weblogic domain directory: D:\bea\mydomain
Path to log4j.properties file: 
D:\bea\mydomain\mydirectory\config\log4j.properties.

Prior to fix, I passed: 
-Dlog4j.configuration="mydirectory\config\log4j.properties". Btw, I pass log4j 
configuration in this way when I run weblogic manually.
In the fix, I passed: 
-Dlog4j.configuration="file:///D:\bea\mydomain\mydirectory\config\log4j.properties"

In the static block of class org.apache.log4j.LogManager, the path to 
log4j.properties was taken as a url. Snippet from LogManager is pasted.
line 108:   try {
      url = new URL(configurationOptionStr);
    } catch (MalformedURLException ex) {
      // so, resource is not a URL:
      // attempt to get the resource from the class path
      url = Loader.getResource(configurationOptionStr); 
    }    

So, I just changed the path from current directory to a file url. That fixed 
it. I tried putting log4j.properties file in system classpath. It didn't work 
and hence I took the file url approach. Any wild guess why log4j wouldn't pick 
up from classpath?

Thanks,
Abbas

----- Original Message ----
From: Jacob Kjome <[EMAIL PROTECTED]>
To: Log4J Users List <log4j-user@logging.apache.org>; Mirza Abbas Raza <[EMAIL 
PROTECTED]>
Sent: Thursday, September 28, 2006 2:43:23 PM
Subject: Re: log4j doesn't log files when weblogic is run as a windows service.


I'm glad you figured it out.  But it would be nice to know what was happening
before?  Had you provided -Dlog4j.configuration to the command line previously
or just counted on Log4j to auto-discover it on the classpath?

Jake

Quoting Mirza Abbas Raza <[EMAIL PROTECTED]>:

> The fix is so simple. LogManager loads the properties file using the URL. I
> just provided file url and it was all done. Thanks for your help, Jacob.
> -Abbas
>
> ----- Original Message ----
> From: Jacob Kjome <[EMAIL PROTECTED]>
> To: Log4J Users List <log4j-user@logging.apache.org>; Mirza Abbas Raza
> <[EMAIL PROTECTED]>
> Sent: Wednesday, September 27, 2006 2:11:15 PM
> Subject: Re: log4j doesn't log files when weblogic is run as a windows
> service.
>
>
> Did you ever try setting log4j.debug=true in your property file?  What does
> it
> spit out to the console?  I don't recall if you can set this as a system
> property or not?  Look at LogManager.java for something like "log4j.debug".
> In
> that case, you could do -Dlog4j.debug=true.
>
> If you see no output to Weblogic's console log after setting it in the
> properties file, then I would suspect that some other config file is getting
> picked up in preference to your own.  In that case, hopefully the system
> property would help.
>
>
> Jake
>
> Quoting Mirza Abbas Raza <[EMAIL PROTECTED]>:
>
> > I think log4j.properties is being read by the application. I verified this
> in
> > the same way you mentioned.
> >
> > 1. Wrote a method in my Struts Action to read the "log4j.configuration"
> from
> > system variables. Using the value read by this variable, I did a
> > fileinputstream and loaded into Properties. Then, I could read all the
> > properties from the log4j.properties file.
> > 2. In the same Struts Action, I 'stepped into' using eclipse debugger into
> > Logger.getLogger(clazz) stack. Log4j tried to get an appender all the way
> to
> > the root, but didn't find one.
> >
> > thanks,
> > Abbas
> >
> > ----- Original Message ----
> > From: Jacob Kjome <[EMAIL PROTECTED]>
> > To: Log4J Users List <log4j-user@logging.apache.org>; Mirza Abbas Raza
> > <[EMAIL PROTECTED]>
> > Sent: Wednesday, September 27, 2006 1:38:12 PM
> > Subject: Re: log4j doesn't log files when weblogic is run as a windows
> > service.
> >
> >
> > It's probably that the config file never gets put in the classpath when you
> > run
> > as a service.  I think you've claimed previously that you verified that it
> > was
> > in the classpath, but that's hard to believe.
> >
> > Why don't you do this.  In some class (or a JSP), try to load up the config
> > file
> > as an inputstream from the classpath.  If you are able to find it when
> > running
> > as a service, you will have ruled out this as a problem.  However, if the
> > inputstream is null, then it will be proven that the config file is not in
> > the
> > classpath.
> >
> >
> > Jake
> >
> > Quoting Mirza Abbas Raza <[EMAIL PROTECTED]>:
> >
> > > Jacob,
> > >
> > > So, I got 1.2.14 version of log4j and ran the application as a service
> and
> > > manually. I plugged in eclipse debugger to see where the problem was. I
> > found
> > > that when I run manually, the appenders are getting created.
> Specifically,
> > > variable 'aai' has an instance of AppenderAttachableImpl for an appender,
> > in
> > > the callAppenders() api of Category class. However, 'aai' is null when
> the
> > > application is run as windows service. Appreciate your help.
> > >
> > > Thanks,
> > > Abbas
> > >
> > >
> > > ----- Original Message ----
> > > From: Jacob Kjome <[EMAIL PROTECTED]>
> > > To: Log4J Users List <log4j-user@logging.apache.org>
> > > Sent: Monday, September 18, 2006 2:24:38 PM
> > > Subject: Re: log4j doesn't log files when weblogic is run as a windows
> > > service.
> > >
> > >
> > > A few quesions/comments...
> > >
> > > 1.  What version of Log4j are you using?  I think at some point, there
> was
> > a
> > > feature implemented which allowed Log4j to create any needed directories.
> > > This
> > > hadn't been the case previously.  I think it got implemented maybe post
> > > 1.2.9,
> > > but I'm not positive.  So, it might make sense that the directories got
> > > created.
> > >
> > > 2.  Clearly Weblogic's service is setting the startup directory if you
> find
> > > your
> > > directories being created under "mydomain".
> > >
> > > 3.  Are you sure that log4j.properties is getting picked up?  Is it
> > possible
> > > some other config file is getting picked up?  If log4j finds log4j.xml,
> it
> > > will
> > > be used in preference to log4j.properties.  Also, try setting
> > > log4j.debug=true.
> > > Maybe you'll see some extra output.  Add a console appender to make sure
> > you
> > > see
> > > this output.  It should turn up in Weblogic's console log file.
> > >
> > >
> > > Jake
> > >
> > > Quoting Mirza Abbas Raza <[EMAIL PROTECTED]>:
> > >
> > > > So, Jake, here is what I did but didn't succeed.
> > > >
> > > > Excerpt from log4j.properties file.
> > > > # Specify the R log file
> > > > log4j.appender.R=org.apache.log4j.DailyRollingFileAppender
> > > > log4j.appender.R.File=logs/node/mylog.log
> > > > log4j.appender.DAILY.DatePattern='.'yyyy-MM-dd
> > > >
> > > > Scenario 1: Run as is.
> > > > - checked C:\winnt\system32.
> > > > - obviously no logs found.
> > > >
> > > > Scenario 2: Created directories logs/node in C:\winnt\system32.
> > > > - stopped service and restarted.
> > > > - no logs found in C:\winnt\system32\logs\node directory.
> > > >
> > > > Scenario 3: Changed log4j.appender.R.File=logs/node/mylog.log to
> > > > D:\mydirectory\domains\mydomain/logs/node/mylog.log
> > > > - stopped and restarted service.
> > > > - no logs found  in
> D:\mydirectory\domains\mydomain/logs/node/mylog.log.
> > > >
> > > > I couldn't find a way to specify the startup directory with the
> weblogic
> > > > utility or the Java Service Wrapper and hence couldn't test it.
> However,
> > I
> > > > saw an interesting point in the properties for the service.
> > > > "D:\mydirectory\domains\mydomain\wrapper.exe -s
> > > > D:\mydirectory\domains\mydomain\conf\managedwrapper.conf". The
> logs/node
> > > > directory is located in mydomain directory. Wouldn't this point the
> logs
> > to
> > > > the right directory?
> > > >
> > > > Thanks,
> > > > Abbas
> > > >
> > > >
> > > > ----- Original Message ----
> > > > From: Jacob Kjome <[EMAIL PROTECTED]>
> > > > To: Log4J Users List <log4j-user@logging.apache.org>; Mirza Abbas Raza
> > > > <[EMAIL PROTECTED]>
> > > > Sent: Monday, September 18, 2006 11:57:20 AM
> > > > Subject: Re: log4j doesn't log files when weblogic is run as a windows
> > > > service.
> > > >
> > > >
> > > > I'll bet they *do* get created.  You just don't know where to look.
> What
> > > > does
> > > > your config look like?  Does it use relative paths to the files?  Keep
> in
> > > > mind,
> > > > relative paths are relative to the directory from which the JVM
> started.
> > > So,
> > > > if
> > > > you start on the command line, the path in the config file is relative
> to
> > > the
> > > > current directory in the command shell.
> > > >
> > > > OTOH, When you start up using a service, unless you define the startup
> > > > directory, it will default to "C:\WINDOWS\system32" (or the equivalent
> on
> > > > your
> > > > windows box).  Furthermore, if your path includes a directory name,
> such
> > as
> > > > "./logs/mylog.log", and said directory doesn't exist already under
> > > > "C:\WINDOWS\system32", then Log4j won't bother creating it for you.
> You
> > > have
> > > > to make sure it exists before Log4j can write to the location.
> > > >
> > > > Look into that and let us know what you find.
> > > >
> > > > Jake
> > > >
> > > > Quoting Mirza Abbas Raza <[EMAIL PROTECTED]>:
> > > >
> > > > > All,
> > > > >
> > > > > The log4j framework doesn't seem to write to the logs when weblogic
> is
> > > run
> > > > as
> > > > > windows service. As I understand, the two things needed for the log4j
> > > > > framework are:
> > > > > - log4j.jar in classpath
> > > > > - log4j.properties as -Dlog4j.configuration. It contains the
> necessary
> > > > > configuration for logging.
> > > > >
> > > > > Both of the above mentioned artifacts are found correctly configured
> in
> > > the
> > > > > utilities that were used to create the windows service. I have used
> > both
> > > > bea
> > > > > provided utility and Java Service Wrapper from Tanuki Software. When
> > > > weblogic
> > > > > is started after the service installation, log files that were
> supposed
> > > to
> > > > be
> > > > > created by log4j don't appear. The ironic part is that when weblogic
> is
> > > > > started manually, the log files do appear. Is there a known
> workaround
> > > for
> > > > > this scenario? I appreciate any help.
> > > > >
> > > > > Environment info:
> > > > > OS - Windows 2000 server
> > > > > JDK - 1.4.2
> > > > > Weblogic - 8.1
> > > > > log4j - 1.2.7
> > > > >
> > > > > Thanks,
> > > > > Abbas
> > > > >
> > > > >
> > >
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > 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]
>
>
>
>
>
>





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





Reply via email to