Wildfly does not write the logs to server.log file - jboss

I have a maven project running on Wildfly 10 . Widfly 10 does not write the error logs or warn logs to the server.log file .
My configuration of standalone.xml file is as follows
<subsystem xmlns="urn:jboss:domain:logging:3.0">
<console-handler name="CONSOLE">
<level name="INFO"/>
<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.jboss.as.config">
<level name="DEBUG"/>
</logger>
<logger category="sun.rmi">
<level name="WARN"/>
</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>
Please help me !!

The problem is probably not within your configuration, but within your deployment. You might have logging-libraries or logging-configuration within your deployment.

Related

Log4j - Log file not getting sent to external log viewer

I have a pod that uses a log4j2.xml config file to manage logging configuration and for sending it to an external log viewer (Elastic Search). This pod has two log files that need to sent to Elastic Search. A main log file and a ruletrace log file. This is the log4j config file:
<?xml version="1.0" encoding="UTF-8"?>
<Configuration monitorInterval="30">
<Properties>
<Property name="logFolder">/var/log/svc</Property> <!-- Must NOT end with a slash -->
</Properties>
<appenders>
<Console name="console" target="SYSTEM_ERR">
<PatternLayout pattern="%d{ISO8601};%p;[%t];%logger;%msg\n"/>
</Console>
<RollingRandomAccessFile name="allLogRollingFileAppender"
fileName="${logFolder}/svc.log"
filePattern="${logFolder}/svc-%d{yyyy-MM-dd}T%d{HH-mm}_%i.log.gz"
immediateFlush="false">
<PatternLayout pattern="%d{ISO8601};%p;[%t];%logger;%msg\n"/>
<Policies>
<CronTriggeringPolicy schedule="0 0 0 * * ?"/>
<SizeBasedTriggeringPolicy size="20 MB" />
</Policies>
<DefaultRolloverStrategy>
<Delete basePath="${logFolder}" maxDepth="1">
<IfFileName glob="svc-*.gz">
<IfAccumulatedFileSize exceeds="100 MB" />
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
<RollingRandomAccessFile name="ruleTraceRollingFileAppender"
fileName="${logFolder}/svc_ruletrace.log"
filePattern="${logFolder}/svc_ruletrace-%d{yyyy-MM-dd}T%d{HH-mm}_%i.log.gz"
immediateFlush="true">
<PatternLayout pattern="%m%n"/>
<Policies>
<CronTriggeringPolicy schedule="0 0 0 * * ?"/>
<SizeBasedTriggeringPolicy size="30 MB" />
</Policies>
<DefaultRolloverStrategy>
<Delete basePath="${logFolder}" maxDepth="1">
<IfFileName glob="svc_ruletrace*.gz">
<IfAccumulatedFileSize exceeds="100 MB" />
</IfFileName>
</Delete>
</DefaultRolloverStrategy>
</RollingRandomAccessFile>
<Syslog name="sysLogAppender"
format="RFC5424"
advertise="false"
host="localhost"
port="5140"
protocol="UDP"
facility="local6"
appName="svc"
enterpriseNumber="193"
mdcId="svcMdcId"
includeMDC="false"
newLine="true"
exceptionPattern="%throwable{full}"
immediateFlush="false">
<MarkerFilter marker="RULETRACE" onMatch="DENY" onMismatch="ACCEPT"/>
</Syslog>
</appenders>
<loggers>
<Logger name="RuleTrace" level="debug" includeLocation="false" additivity="false">
<AppenderRef ref="ruleTraceRollingFileAppender"/>
</Logger>
<Logger name="com.comp" level="info" additivity="true">
<AppenderRef ref="allLogRollingFileAppender"/>
</Logger>
<root level="info">
<AppenderRef ref="console" level="fatal"/>
<AppenderRef ref="sysLogAppender" level="info"/>
</root>
</loggers>
</Configuration>
The main log file (svc.log) gets sent to ElasticSearch with no issues. The ruletrace doesn't, however. There are log messages appearing in the ruletrace log file on the pod but those log messages don't get sent to ElasticSearch. I've tried changing the settings below a few times to different configs but it makes no difference, seemingly.
Is there a limit to the amount of Loggers you can reference? Would the difference in pattern layout make a difference?

Stop log4net (or services) using a file when errors are not being placed in it

I have the following log4net config
<?xml version="1.0" encoding="utf-8" ?>
<log4net xmlns="urn:log4net">
<appender name ="RollingFile" type="log4net.Appender.RollingFileAppender">
<file value="C:\temp\Generator.log" />
<appendToFile value="true" />
<rollingStyle value="Size" />
<maximumFileSize value="500KB" />
<maxSizeRollBackups value="10" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{DATE} %level %thread %logger - %message%newline" />
</layout>
</appender>
<appender name ="GenerationErrors" type="log4net.Appender.FileAppender">
<file type="log4net.Util.PatternString" value="c:\temp\GenerationErrors.log" />
<appendToFile value="true" />
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date{DATE} %level %thread %logger - %message%newline" />
</layout>
</appender>
<root>
<appender-ref ref="RollingFile" />
<level value="INFO" />
</root>
<logger name ="GPA.Module.Generate">
<level value="INFO" />
<appender-ref ref="GenerationErrors" />
</logger>
<logger name="PmuManagement">
<level value="INFO" />
<appender-ref ref="GenerationErrors" />
</logger>
</log4net>
The first appender logs all errors for all of my processes and the second only logs a certain group of errors, as required.
I need to be able to delete the contents of the second log file on the fly however this isn't currently possible as the programme needs constant access to it to run (if you try and make any changes you get the "this file is in use by another programme" error.
Is there a way for log4net to only need access to the file when errors need to be written to it?
Or is there a more generic way to stop services/programmes needing access to file temporarily and allowing access again shortly after?
Thanks
I found this question here Intermittent log4net RollingFileAppender locked file issue and the answer is what I needed. I simply added <lockingModel type="log4net.Appender.FileAppender+MinimalLock" /> to my second appender.

Log4Net today's backup file does not have date in file name

Below mentioned Log4Net, having date in file name if date is <= yesterday, however files which are back up today, does not have date in file name.
Is it the specification of Log4Net?
Or
It is because of some setting of Log4Net config file?
File
<?xml version="1.0" encoding="UTF-8"?><configuration>
<log4net>
<logger name="SampleLog">
<level value="FATAL"/>
<level value="ERROR"/>
<level value="WARN"/>
<level value="INFO"/>
<level value="DEBUG"/>
<appender-ref ref="SampleLogFile"/>
</logger>
<appender name="SampleLogFile" type="log4net.Appender.RollingFileAppender">
<file type="log4net.Util.PatternString" value="%property{SampleService}"/>
<appendToFile value="true"/>
<maxSizeRollBackups value="15"/>
<maximumFileSize value="1KB"/>
<rollingStyle value="Composite"/>
<datePattern value="yyyyMMdd"/>
<staticLogFileName value="true"/>
<Encoding value="UTF-8"/>
<layout type="log4net.Layout.PatternLayout">
<!-- %d:DateTime, %t:Thread, %-5p:Categories, %c:LoggerName, %m:Message, %n:line separator-->
<param name="ConversionPattern" value="%p %d{ISO8601} %t %m%n"/>
</layout>
</appender>
</log4net>
</configuration>
File name example :
Application_Sample.log // Currently in progress log
Application_Sample.log.1 // Today's backup
Application_Sample.log20190801.2 // Yesterday's backup
You just specify the rollingStyle as Composite, so RollingFileAppender will roll log files on a date period and within a date period on file size. For each day only the last 10 files of 1MB will be kept. And these rolled files will be named: log.txt.1, log.txt.2, log.txt.3, etc. Youcan find the details via https://logging.apache.org/log4net/release/config-examples.html#RollingFileAppender

Will this log4j configuration file create application.log files appended with the timestamp?

I have a log4j configuration file that looks like:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/' debug="false">
<appender name="consoleAppender"
class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="INFO" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d
%-5p [%c{1}] %m %n" />
</layout>
</appender>
<appender name="fileAppender"
class="org.apache.log4j.DailyRollingFileAppender">
<param name="Threshold" value="INFO" />
<param name="File" value="/var/output/logs/application.log"/>
<param name="DatePattern" value=".yyyy-MM-dd" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d{yyyy-MMM-dd HH:mm:ss,SSS} [%t] %c %x%n %-5p %m%n"/>
</layout>
</appender>
<logger name="connect.testJava" additivity="false" >
<level value="DEBUG" />
<appender-ref ref="consoleAppender"/>
<appender-ref ref="fileAppender"/>
</logger>
</log4j:configuration>
I wanted to basically create logs with the format application.log like application2013-06-12 12:12:00.log or something like that. The above configuration does not seem to be doing that. Can someone please help me out and tell me what I might be doing wrong? I am just about a couple of hours into log4j, so sorry if this question sounds too naive.
Yes it does. Just wait till midnight and a new file will be created. The day's file will remain application.log

No Log4J output in sbt when using scalatest

I'm using Log4J for logging in SBT. In a configuration file, I've defined the TRACE level for the root node. When I run the project (sbt run) all debug output is displayed correctly. But when I run the tests (sbt test), no output at all is generated. I need to insert the class into the configuration to see the output.
The test are written in a JUnit style. Executing the tests with Eclipse shows all Log4J Output. So, it seems to be an issue with SBT or scalatest.
Log4J Configuration:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration debug="false" xmlns:log4j="http://jakarta.apache.org/log4j/">
<appender name="stdout" class="org.apache.log4j.ConsoleAppender">
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%-5r [%-5p] %c: %M - %m%n"/>
</layout>
</appender>
<appender name="asyncApp" class="org.apache.log4j.AsyncAppender">
<appender-ref ref="fileApp"/>
</appender>
<appender name="fileApp" class="org.apache.log4j.FileAppender">
<param name="File" value="testlog_Compiler"/>
<param name="Append" value="true" />
<param name="Threshold" value="ALL"/>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%d [%-5p] %c: %M - %m%n"/>
</layout>
</appender>
<appender name="fileAppTest" class="org.apache.log4j.FileAppender">
<param name="File" value="testlog_Tests"/>
<param name="Append" value="true" />
<param name="Threshold" value="ALL"/>
<layout class="org.apache.log4j.EnhancedPatternLayout">
<param name="ConversionPattern" value="%d [%-5p] %c: %M - %m%n"/>
</layout>
</appender>
<logger name="main.Main$" additivity="true">
<level value="INFO" />
</logger>
<!--
<logger name="compile.Compiler" additivity="true">
<level value="DEBUG" />
</logger>
-->
<logger name="test" additivity="false">
<level value="TRACE" />
<appender-ref ref="stdout"/>
<appender-ref ref="fileAppTest"/>
</logger>
<root>
<priority value="TRACE"/>
<appender-ref ref="asyncApp"/>
<appender-ref ref="stdout"/>
</root>
</log4j:configuration>
When I use this version of the config file, the tests of compile.Compiler don't generate any log output unless I uncomment its node in the Log4J config. In the SBT configuration file, these dependencies are defined for compile.Compiler: (This is just a minimal example.)
class Comp2011ParentProject(info: ProjectInfo) extends DefaultProject(info) {
val compiler = project("compile", "compile", new Compile(_))
class compiler(info: ProjectInfo) extends DefaultProject(info) with Eclipsify {
val scalatest = "org.scalatest" % "scalatest_2.9.0" % "1.6.1"
val junitInterface = "com.novocode" % "junit-interface" % "0.6" % "test->default"
val log4j = "log4j" % "log4j" % "1.2.16"
val log4jExtras = "log4j" % "apache-log4j-extras" % "1.1"
}
}
Does anyone have a clue why this happens and how to stop it?
(Unfortunately I lost my account which posted this question. :-( But this is also some kind of answer.)
Further investigations showed that at some point in code the level for the compile.Compiler logger was manually set to INFO. When I delete this statement, everything works fine.
The surprising fact about this is that setting the level in one test also causes all the following tests to adopt that logging level. This was hard to understand because I thought the configuration file was reloaded with every new test.
However, after some documentation surfing, I found out that the actual configuration is not reset when loading a configuration file. To have this behavior a BasicConfigurator.resetConfiguration() must be executed before loading the configuration. With this, everything works as expected.