Discussion:
[whispersystems] TextSecure-Server logging
Jeff R
2015-09-01 17:06:41 UTC
Permalink
Hi all,

I have a TextSecure server up and running. I'm well aware it's not
supported. But, can someone teach the village idiot of java how to log to a
file instead of the console? :)

I'm assuming it will have something to do with this:
http://stackoverflow.com/questions/20328646/org-slf4j-logger-logs-to-console-how-do-i-log-to-file

Thanks!

Jeff
Eric Hartsuyker
2015-09-01 17:16:07 UTC
Permalink
Below is a snippet of the log4j file I use.

Add this to your classpath / pom.xml: Group: "org.slf4j", Artifact:
"slf4j-log4j12", Version: "1.7.12"

Start the JVM with:

java -cp <whatver> -Dlog4j.debug
-Dlog4j.configuration=file:/some/where/local/log4j.xml

Right at the JVM starts you should see messages saying that log4j is
initializing (written to stdout), and then you will get log messages
written to both the file you specified and the console.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">

<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p] %-d{yyyy-MM-dd HH:mm:ss}
[%c{1}:%t] %m%n"/>
</layout>
</appender>

<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="/some/file/somewhere"/>
<param name="append" value="true"/>
<param name="encoding" value="UTF-8"/>

<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p] %-d{yyyy-MM-dd HH:mm:ss}
[%c{1}:%t] %m%n" />
</layout>
</appender>

<appender name="async" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="console"/>
<appender-ref ref="file"/>
</appender>

<root>
<priority value="info"/>
<appender-ref ref="async" />
</root>

</log4j:configuration>
Post by Jeff R
Hi all,
I have a TextSecure server up and running. I'm well aware it's not
supported. But, can someone teach the village idiot of java how to log to a
file instead of the console? :)
http://stackoverflow.com/questions/20328646/org-slf4j-logger-logs-to-console-how-do-i-log-to-file
Thanks!
Jeff
Jeff R
2015-09-02 05:09:03 UTC
Permalink
Thanks Eric! I'll give that a try.

Jeff
Post by Eric Hartsuyker
Below is a snippet of the log4j file I use.
"slf4j-log4j12", Version: "1.7.12"
java -cp <whatver> -Dlog4j.debug
-Dlog4j.configuration=file:/some/where/local/log4j.xml
Right at the JVM starts you should see messages saying that log4j is
initializing (written to stdout), and then you will get log messages
written to both the file you specified and the console.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p] %-d{yyyy-MM-dd HH:mm:ss}
[%c{1}:%t] %m%n"/>
</layout>
</appender>
<appender name="file" class="org.apache.log4j.RollingFileAppender">
<param name="file" value="/some/file/somewhere"/>
<param name="append" value="true"/>
<param name="encoding" value="UTF-8"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="[%p] %-d{yyyy-MM-dd HH:mm:ss}
[%c{1}:%t] %m%n" />
</layout>
</appender>
<appender name="async" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="console"/>
<appender-ref ref="file"/>
</appender>
<root>
<priority value="info"/>
<appender-ref ref="async" />
</root>
</log4j:configuration>
Post by Jeff R
Hi all,
I have a TextSecure server up and running. I'm well aware it's not
supported. But, can someone teach the village idiot of java how to log to a
file instead of the console? :)
http://stackoverflow.com/questions/20328646/org-slf4j-logger-logs-to-console-how-do-i-log-to-file
Thanks!
Jeff
Loading...