22.2.06

OC4J (9.0.4, 10.1.2 and 10.1.3) log file rotation

For those that want to rotate the OC4J log files under $ORACLE_HOME/opmn/logs, there are new parameters not documented in 9.0.4/10.1.2 documentation:

[New JVM parameters]
"stdstream.filesize"
Max file size limit of each archive. Unit is megabyte.
"stdstream.filenumber"
Max number of files that oc4j can keep as archives. The oldest file
will be automatically deleted if the limit is exceeded.
"stdstream.rotatetime"
Time when the log file is rotated. Format is "HH:mm". The archive
will be rotated at the specified time everyday.

[Usage]
ex 1: rotate stdout/stderr when the file size is reached to 2.5M byte.
java -Dstdstream.filesize=2.5 -jar oc4j.jar -out std.out -err std.err
ex 2: rotate stdout at 13:30 everyday
java -Dstdstream.rotatetime=13:30 -jar oc4j.jar -out std.out
ex 3: rotate stdout at 13:30 everyday and keep 10 files as archive
java -Dstdstream.rotatetime=13:30 -Dstdstream.filenumber=10 -jar oc4j.jar -out std.out

The generated log file would look like <filename w/o extension>_yyyy_MM_dd_HH_mm_ss.<extension>
e.g. std_2004_07_08_13_24_53.out

[Note]
1. The same parameter are used for both "-out" and "-err".
2. In AS mode, the log files will be created under <island name and process id> directory
(this isn't changed by this fix, existing code handles this)
3. Both "filesize" and "rotatetime" parameters can be used at the same time.

opmn.xml
In order to get these parameters in opmn.xml you need to define it as follows:
...
<category id="start-parameters">
<data id="java-options" value="-server -Djava.security.policy=$ORACLE_HOME/j2ee/home/config/java2.policy -Djava.awt.headless=true -Dstdstream.filesize=0.2 -Dstdstream.filenumber=5"/>
<data id="oc4j-options" value="-out std.out -err std.err"/>
</category>
...

You will find the new log files under:$ORACLE_HOME/j2ee/home/home_default_island_1

The file naming will be like:
std_2006_02_22_14_01_17.out
std_2006_02_22_14_16_25.out

10 comments:

Anonymous said...

I have no "opmn" subdirectory in my OC4J 10.1.2.0.2 stand-alone installation.

I have an "opmn" subdirectory in all my OC4J 10.1.3.x.x stand-alone installations, including 10.1.3.0.0, 10.1.3.1.0 and 10.1.3.2.0, but there is no "logs" subdirectory under "opmn", only "lib".

Are you sure your blog relates to OC4J stand-alone?
Or is it for Oracle Application Server (OAS).
They aren't the same thing, I hope you realize.

Log rotation is documented and can be achieved for OC4J stand-alone by configuring ODL.
It is detailed in the documentation.

Good Luck,
Avi.

Harri Kaukovuo said...

Avi, as being the working with OracleAS for many years, I have indeed realized the difference between standalone OC4J and normal installation.

If you are running standalone OC4J containers you need to manually take care of passing the parameters for OC4J container when you startup the engine.

Log rotation was not documented in earlier versions.

-- Harri

Anonymous said...

Is it possible to change the log file name format?

Current the log file name format is
logfilename_TIME.extenstion
Can we change log file name similar to
logfilename.ext.1
logfilename.ext.2
logfilename.ext.3
with current one as logfilename.ext.log

Ambrose said...

Hi Harri,

My current soa logfile is SOA_GROUP~OC4J_SOA~SOA_GROUP~1.log, is it possible to rotate the file so that it looks something like SOA_GROUP~OC4J_SOA~SOA_GROUP~2.log, SOA_GROUP~OC4J_SOA~SOA_GROUP~3.log and so on and not a separate .out and .err file in a different location.

Thanks,
Amby.

AshrafTP said...

Hi Harri,

As ambrose said..Can u please tel how to rotate OA_GROUP~OC4J_SOA~SOA_GROUP~1.log, .

My current soa logfile is SOA_GROUP~OC4J_SOA~SOA_GROUP~1.log, is it possible to rotate the file so that it looks something like SOA_GROUP~OC4J_SOA~SOA_GROUP~2.log, SOA_GROUP~OC4J_SOA~SOA_GROUP~3.log and so on and not a separate .out and .err file in a different location.

Bhajan Mehta said...

First of all thanks a lot for such a nice article.
I have one more question for log file name, logfilename_YYYY_mm_dd_hh_mm_ss.log
Can we remove "time" from the file name ?
I am expecting file name as logfilename_YYYY_mm_dd.log

Bhajan Mehta said...

Dear Ambrose/Ashraf,

I got the solution for have SINGLE file for logging instead of TWO seprate files (.out and .err), this can be done as:
Append the following line just below where you have given rotation time.

In oc4j-options where you are specifying different file names use same file name with your desired extension.

data id="oc4j-options" value="-out $ORACLE_HOME/opmn/logs/FILE_NAME.log -err $ORACLE/opmn/logs/FILE_NAME.log

Anonymous said...

Guys,
Is it possible to have the std_2006_02_22_14_01_17.out in the std_2006_02_22.out format [ without Time ]

Debashis Dana said...

hi Harri,

thanks for wonderful post.i was exactly find this. i have some problem..
1. oc4j logs is not updating after it reaches 2 GB (2147483647), i checked in opmn.xml, not found correct things..please help me out

-rw-r--r-- 1 ora703p dba 2147483647 Apr 4 01:40 OC4J~Cramer6~default_island~1.12-04-13_22:33:10
-rw-r--r-- 1 ora703p dba 2147483647 Apr 17 09:33 OC4J~Cramer6~default_island~1.12-04-19_14:02:39
-rw-r--r-- 1 ora703p dba 2147483647 Apr 19 13:52 OC4J~Cramer6~default_island~1.19-4-13-13_51_04
-rw-r--r-- 1 ora703p dba 2147483647 Apr 24 10:25 OC4J~Cramer6~default_island~1-24-4-2012
-rw-r--r-- 1 ora703p dba 0 Apr 24 10:26 OC4J~Cramer6~default_island~1
SZ0002:(ora703p):/orad0703p_sw/ora0703p/product/RES/as1012/opmn/logs$


2. after making separation or err and out file( please see below syntax)in file conf file opmn.xml, we found that this is not correctly updating


data id="oc4j-options" value="-properties -out $ORACLE_HOME/opmn/logs/RMmstd.out -err $ORACLE_HOME/opmn/logs/RMmstd.err

any suggestion?

icekk said...

Hi Guys !
My current environment is OAS 10.1.3.5 in cluster mode. I want to rollover my opmn logs which are are generated group wise at $ORACLE_HOME\opmn\logs