Rolling file on utc date rather than server date - time

This is my log4net.xml file
<log4net>
<appender name="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\MVC2-" > </file>
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyy'-'MM'-'dd'.log'" />
<dateTimeStrategy type="log4net.Appender.RollingFileAppender+UniversalDateTime" />
<lockingModel type="log4net.Appender.FileAppender+MinimalLock" />
<staticLogFileName value="false" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%utcdate %level %property{requestId} %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="RollingFile" />
</root>
</log4net>
The log dates are in UTC, but the file rolls over to the next day on server time. This results in some hours of logs being recorded in the wrong file.
How do I make the file roll over depending upon the utc time?

The general answer is that you are going to need to open up log4net and modify it to allow this. However, if you don't want to do all the legwork yourself, you could use the code posted in the link below to use as a jump-start:
http://old.nabble.com/svn-commit%3A-r398209----logging-log4net-trunk-src-Appender-RollingFileAppender.cs-to4156618.html#a4156618

Related

How to properly import JavaFX librarys?

I am using IntellIJ and just created a JavaFX sample project. I have not done any changes to the code but I am getting this Error:
Error: JavaFX runtime components are missing, and are required to run this application
my project.iml:
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library name="javafx-fxml">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/16/javafx-fxml-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-fxml/16/javafx-fxml-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/16/javafx-controls-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-controls/16/javafx-controls-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/16/javafx-graphics-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-graphics/16/javafx-graphics-16-win.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/16/javafx-base-16.jar!/" />
<root url="jar://$MAVEN_REPOSITORY$/org/openjfx/javafx-base/16/javafx-base-16-win.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>
Why doesn't the library in project.iml work?
You need to download JavaFX SDK and connect it to the project as a library. See the detailed guide in JetBrains official documentation
and pay attention to this section
And don't forget to define these libraries in VM options of a run configuration in use. See this

SOAP Service Logger not sending data to proper file

Below is the snippet from my log4j.xml which sets up the logging for all Soap Service messaging. Unfortunately I'm not seeing any of the SOAP data being logged to my logfile. Errors are logged but the actual message request/response is not getting logged.
Am I missing something? Based on all of the information I've read it seems to be setup properly.
<appender name="WS_REQUEST_LOG" class="org.apache.log4j.RollingFileAppender">
<param name="File" value="${log4j.ws-req}" />
<param name="maxFileSize" value="50MB" />
<param name="maxBackupIndex" value="40" />
<param name="ImmediateFlush" value="true" />
<layout class="common.log.PatternLayout"></layout>
</appender>
<!-- Write responses to web services received to rolling log -->
<logger name="org.springframework.ws.server.MessageTracing" additivity="false">
<level value='TRACE'/>
<appender-ref ref="WS_REQUEST_LOG" />
</logger>
<!-- Write web services received to rolling log -->
<logger name="org.springframework.ws.client.MessageTracing" additivity="false">
<level value='TRACE' />
<appender-ref ref="WS_REQUEST_LOG" />
</logger>

How do we redirect logs for spring using appenders

I want to redirect spring logs and logs generated from log4j to a separate file using appenders.
Is the below approach correct? Also, How can I redirect logs from log4j to a different file. Please advice.
<!-- Logger for Spring
<category name="org.springframework">
<level value="DEBUG"/>
<appender-ref ref="Spring"/>
</category>
-->
<appender name="Spring" class="org.apache.log4j.DailyRollingFileAppender">
<param name="File" value="./logs/spring.log"/>
<param name="Append" value="false"/>
<param name="BufferedIO" value="true"/>
<param name="DatePattern" value="-yyyy-MM-dd-HH"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%x [%d{MMM dd, yyyy
HH:mm:ss}] [%t] %-5p [%c] - %m%n"/>
</layout>
</appender>

Get spring framework logging in wildfly

I was trying to get Spring 4 to log in Wildfly 8.2. I wanted spring to use the wildfly logging configuration.
All the examples I could find were trying to complicate this process by adding additional logging frameworks and configuration.
So here is how I did it, for prosperity.
To get spring 4 to log in wildfly 8, I had to add the following to the logging subsystem config in the standalone.xml file.
<add-logging-api-dependencies value="false"/>
<use-deployment-logging-config value="false"/>
Additionally to get debug logging
<logger category="org.springframework">
<level name="DEBUG"/>
</logger>
Here is the full subsystem config:
<subsystem xmlns="urn:jboss:domain:logging:2.0">
<add-logging-api-dependencies value="false"/>
<use-deployment-logging-config value="false"/>
<console-handler name="CONSOLE">
<level name="DEBUG"/>
<formatter>
<named-formatter name="COLOR-PATTERN"/>
</formatter>
</console-handler>
<periodic-rotating-file-handler name="FILE" autoflush="true">
<formatter>
<named-formatter name="PATTERN"/>
</formatter>
<file relative-to="jboss.server.log.dir" path="server.log"/>
<suffix value=".yyyy-MM-dd"/>
<append value="true"/>
</periodic-rotating-file-handler>
<logger category="com.arjuna">
<level name="WARN"/>
</logger>
<logger category="org.apache.tomcat.util.modeler">
<level name="WARN"/>
</logger>
<logger category="org.springframework">
<level name="DEBUG"/>
</logger>
<logger category="org.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</logger>
<logger category="jacorb">
<level name="WARN"/>
</logger>
<logger category="jacorb.config">
<level name="ERROR"/>
</logger>
<root-logger>
<level name="INFO"/>
<handlers>
<handler name="CONSOLE"/>
<handler name="FILE"/>
</handlers>
</root-logger>
<formatter name="PATTERN">
<pattern-formatter pattern="%d{yyyy-MM-dd HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
<formatter name="COLOR-PATTERN">
<pattern-formatter pattern="%K{level}%d{HH:mm:ss,SSS} %-5p [%c] (%t) %s%E%n"/>
</formatter>
</subsystem>
The answer depends on what causes the deployment to break in your deployment.
If you have any of the following logging classes in your classpath that can cause logging to break: logging.properties, jboss-logging.properties, log4j.properties, log4j.xml, jboss-log4j.xml
So for example just run this code (either in your app or in a debugger) and it'll show you if you have the file in the classpath
getClass().getResource("/logging.properties")
Repeat for each of the log files specifed above, if any of those return non-null then you have found your culprit.
At that stage you can either remove the problem logging file, or alternatively use Rian's suggestion of adding <use-deployment-logging-config value="false"/> (you don't need to use add-logging-api-dependencies in that scenario thou).
Another potential issue if you have multiple logging jar files. Keep in mind that wildfly will automatically provide several of those unless you use <add-logging-api-dependencies value="false"/>
I had this similar problem and I got it working thanks to the first answer posted by Rian. Here is my working system:
Server: jBoss EAP 7.1
Framework: Spring 5
Configuration via: yml
Modules: each module has its own independent war deployed
Requirement: Each module must log in a separated file
In the yml file I added the following lines to set the log output to a different file than the standar server.log:
logging:
file: ${SPF_LOGGING_PATH:app-logs/}log-#project.artifactId#-app.log
pattern:
console: "%d %-5level %logger : %msg%n"
file: "%d %-5level [%thread] %logger : %msg%n"
Using this configuration, a file in the output dir is created but no text is been written. So, adding this lines to the logging subsystem section in standalone.xml file, it started to write text from each module:
<add-logging-api-dependencies value="false"/>
<use-deployment-logging-config value="false"/>
Hope this may help anyone facing the same issue.
Cheers!

Why wont my log4net log entries show up in Chainsaw on Windows 7

I'm trying to get log4net to log via udp to chainsaw but its not working on windows 7. My config files are as follows:
<log4net debug="true">
<appender name="trace" type="log4net.Appender.TraceAppender, log4net">
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c - %m%n" />
</layout>
</appender>
<appender name="UdpAppender" type="log4net.Appender.UdpAppender">
<remoteAddress value="127.0.0.1" />
<remotePort value="8085" />
<layout type="log4net.Layout.XmlLayoutSchemaLog4j">
<locationInfo value="true" />
</layout>
</appender>
<root>
<level value="TRACE" />
<appender-ref ref="trace" />
<appender-ref ref="UdpAppender" />
</root>
my chainsaw config file looks like this:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="true">
<plugin name="UDPReceiver" class="org.apache.log4j.net.UDPReceiver">
<param name="Port" value="8085" />
</plugin>
</log4j:configuration>
All of this is per the documentation found in: http://logging.apache.org/log4net/release/howto/chainsaw.html
Yet none of the logs show up.
Figured it out. Looks like log4net has issues with ipv6 and windows 7. To get around these issues you need to add an entry into your host file that looks like this:
127.0.0.2 localhosttwo
then your UpdAppender needs to reference that DNS entry as so:
<remoteAddress value="localhosttwo" />
127.0.0.2 is the ipv6 address for your localmachine and you need an explcit dns entry or else log4net will throw an error if you try and use the numerical address in the config file.
Make sure to flush your dns after you change the hostfile

Resources