tags:

views:

1181

answers:

2

Hi All

We all know that WebLogic server creates logs directory under DOMAIN_HOME/servers/SERVER_NAME directory at server start up. But now I want WebLogic to create my application specific logs directory like below at the server startup.

DOMAIN_HOME/servers/SERVER_NAME/logs/myAppLogs/

Where to do the configuration change for this?

Thank you, Chaitanya

+1  A: 

See Change server log file name and location in the Administration Console Online Help.

EDIT: As per comment, the OP actually wants a file appender to create directories of parent-path if they don't exist. I don't know what versions of weblogic nor log4j are used but according to 9150, old versions of log4j don't implement this behavior:

We can't assume log4j will have directory creation permissions, only write permissions to the file specified in the configuration. It's up to the server administrator to control the directory tree.

This should be fixed in version 1.2.12 and later.

PS: I really prefer to find all logs in the same location on a single machine e.g. /var/log/weblogic/<PROJECTNAME>/myApp-${weblogic.Name}.log. It's really easier to find the last file that changed, to grep log files, etc.

Pascal Thivent
I want my applications logs generated using Log4J in particular location.How to do that?
Chaitanya MSV
Does your application have a log4j.properties or a log4j.xml configuration file? This is where it should be configured.
Pascal Thivent
I use log4j.properties but in that I mention log file location as follows: log4j.appender.dailyRollingFile.File=servers/${weblogic.Name}/logs/myAppLogs/myApp.logBut I get the following exception:log4j:ERROR setFile(null,true) call failed.java.io.FileNotFoundException: servers\ms1\logs\myAppLogs\myApp.log (The system cannot find the path specified)
Chaitanya MSV
Thsi is because WebLogic does not create myAppLogs folder by itself. My initial question was to how to make WL create myAppLogs folder so that Log4J can create myApp.log in it. Hope I am clear.
Chaitanya MSV
Well, it's more clear now but 1. you should add these details to your question 2. I don't find it fair to downvote my answer because of your lack of clarity.
Pascal Thivent
I am sorry. It will be reverted.Sorry again.
Chaitanya MSV
I am getting "Vote too old to be changed..." Will change it at appropriate time.
Chaitanya MSV
A: 

Your log4jconfig.xml file should be configured to generate the log file in your desired location. Sample param props in log4jconfg.xml file looks like this

<param name="File" value="DOMAIN_HOME/servers/SERVER_NAME/logs/myAppLogs/MyLog.txt"/>
<param name="Append" value="true"/>
<param name ="MaxFileSize" value="20480KB"/>
<param name="ConversionPattern" value="%d %p %c %x - %m%n"/>
Ravi Gupta