Request How can log4j2.xml be modified

  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

budivudi

New Member
Jul 29, 2019
12
0
0
Hi,

I would like to modify log4j2.xml so that it includes dates in the files. I tried jar xf and jar cf but the resulting jar could not find the manifest.

The patch is:
Code:
--- log4j2.xml.orig     2015-11-10 16:42:16.000000000 +0100
+++ log4j2.xml  2016-07-21 06:18:56.000000000 +0200
@@ -11,7 +11,7 @@
             <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %msg%n" />
         </Queue>
         <RollingRandomAccessFile name="File" fileName="logs/latest.log" filePattern="logs/%d{yyyy-MM-dd}-%i.log.gz">
-            <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level]: %msg%n" />
+            <PatternLayout pattern="[%d{yyyyMMdd-HH:mm:ss}] [%t/%level]: %msg%n" />
             <Policies>
                 <TimeBasedTriggeringPolicy />
                 <OnStartupTriggeringPolicy />
@@ -21,7 +21,7 @@
             <Routes pattern="$${ctx:side}">
                 <Route>
                     <RollingRandomAccessFile name="FmlFile" fileName="logs/fml-${ctx:side}-latest.log" filePattern="logs/fml-${ctx:side}-%i.log">
-                        <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level] [%logger/%X{mod}]: %msg%n" />
+                        <PatternLayout pattern="[%d{yyyyMMdd-HH:mm:ss}] [%t/%level] [%logger/%X{mod}]: %msg%n" />
                         <DefaultRolloverStrategy max="3" fileIndex="max" />
                         <Policies>
                             <OnStartupTriggeringPolicy />
@@ -30,7 +30,7 @@
                 </Route>
                 <Route key="$${ctx:side}">
                     <RandomAccessFile name="FmlFile" fileName="logs/fml-junk-earlystartup.log" >
-                        <PatternLayout pattern="[%d{HH:mm:ss}] [%t/%level] [%logger]: %msg%n" />
+                        <PatternLayout pattern="[%d{yyyyMMdd-HH:mm:ss}] [%t/%level] [%logger]: %msg%n" />
                     </RandomAccessFile>
                 </Route>
             </Routes>

I don't mind running the unzipped jar file but I'm not sure how to do this.

Thanks
 

budivudi

New Member
Jul 29, 2019
12
0
0
Thanks for your reply but I don't get it. log4j.configurationFile does not seem to be set and the ServerStart.sh does not include a -cp argument. So where do I put the log4j2-test.xml or log4j2.xml file?

Do I just repack the jar file and if so what is the command lime?

Thanks
 

budivudi

New Member
Jul 29, 2019
12
0
0
Thanks for your reply but I don't get it. log4j.configurationFile does not seem to be set and the ServerStart.sh does not include a -cp argument. So where do I put the log4j2-test.xml or log4j2.xml file?

Do I just repack the jar file and if so what is the command lime?

Thanks

Well I figured it out and there are quite a few steps after changing the log4j2.xml.

First the command to repack the jar file is:
Code:
cd FTBServer-1.7.10-1558
jar cmf META-INF/MANIFEST.MF ../FTBServer-1.7.10-1558-test.jar .

Next we need to sign the jar file and I followed the instructions https://www.digicert.com/code-signing/java-code-signing-guide.htm using the same alias as in the META-INF directory
Code:
keytool -genkey -alias forge -keyalg DSA -keysize 1024 -keystore keystore.jks
keytool -certreq -alias forge -file csr.csr -keystore keystore.jks
jarsigner -keystore keystore.jks -storepass changeit FTBServer-1.7.10-1558-test.jar forge
jarsigner -verify -verbose -certs FTBServer-1.7.10-1558-test.jar
and finally ran it with the standard command line:
Code:
"$JAVACMD" -server -Xms512M -Xmx2048M -XX:PermSize=256M -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar FTBServer-1.7.10-1558-test.jar nogui

and checked with:
Code:
head -1 logs/latest.log
[20160729-12:10:08] [Server thread/INFO]: Starting minecraft server version 1.7.10

I'll change this again to match the 1.6.4 server log format so I don't need to change the logwatch date processing.

Hope this helps someone else.