intellij : log4j does not output log file - intellij-idea

I am trying to set up log4j in IntelliJ and having an issue. I am able to see console output, but no log file. My config is located at src/main/resources/Log4j2.xml
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="DEBUG">
<Appenders>
<Console name="ConsoleAppender" target="SYSTEM_OUT">
<!--<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n" /> -->
<PatternLayout pattern="%d{HH:mm}%-5level %logger{36} - %msg%n" />
</Console>
<File name="FileAppender"
fileName="productivity.log"
immediateFlush="false"
append="true">
<PatternLayout pattern="%d{yyy-MM-dd HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="ConsoleAppender" />
<AppenderRef ref="FileAppender"/>
</Root>
</Loggers>
</Configuration>
I have done a lot of searching, most of the questions I found simply say to place the log4j2.xml file in src/main/resources, which I did. I also tried the suggestion here but that had no effect.
Also, this is a maven project...
I am currently just trying to run a test that prints one line of text, and no file is created. Any ideas?
Update
After some further testing and going thru the docs I was actually able to get log output, but only when the application context loadded.
When I run a unit test by itself, no log file is created, but I do get the console output.
The log4j2.xml still seems to be ignored, however. I my application.properties I entered
logging.file.path=log
logging.level.root=debug
logging.level.org.springframework.web=debug
and my logging output did come out in the log file, however, I defined my logger like so...
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
// other code deleted for brevity...
private final static Logger logger = LogManager.getLogger(WidgetController.class);
I added this line in the method where the log message was called...
logger.info("in getAllWidgets");
logger.info("logger class : " + logger.getClass());
which created this output:
c.s.w.t.S.controller.WidgetController : in getAllWidgets
c.s.w.t.S.controller.WidgetController : logger class : class org.apache.logging.slf4j.SLF4JLogger
why is the class of the logger class org.apache.logging.slf4j.SLF4JLogger when it was clearly defined as a log4j logger?
if I look in my App/target/classes folder and see my log4j2.xml file there, does that mean it was successfully added to the classpath?
Also, this project was created by SpringInitializr.

Related

Log4j debug messages not going to IntelliJ console

I've got a springboot app using log4j2, and I cannot get logger.debug() messages to go to the console. I've added a log4j2.xml file (below) and am specifying the path to it in my VM options.. but its still not working. Am I missing something? Using log4j 2.17.1.
-Dlog4j2.configurationFile=/Users/home/log4j2.xml
and
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
</Console>
</Appenders>
<Loggers>
<Root level="debug">
<AppenderRef ref="Console"/>
</Root>
</Loggers>
</Configuration>
The following code block...
logger.info("Test info.")
logger.debug("Test Debug.")
logger.warn("Test warn.")
logger.error("Test error.")
results in the following console output
2023-02-15 11:34:02.322 INFO 27001 --- [app] c.b.HelloWorld : Test info.
2023-02-15 11:34:02.322 WARN 27001 --- [app] c.b.HelloWorld : Test warn.
2023-02-15 11:34:02.322 ERROR 27001 --- [app] c.b.HelloWorld : Test error.

How to add HTTP Headers Logback Logstash

I read through the following documentation but cannot figure out what other configuration I need: https://github.com/logstash/logstash-logback-encoder#header-fields
My config file:
<include resource="org/springframework/boot/logging/logback/defaults.xml" />
<include resource="org/springframework/boot/logging/logback/console-appender.xml" />
<property name="LOG_FILE" value="${LOG_FILE:-${LOG_PATH:-${LOG_TEMP:-${java.io.tmpdir:-/tmp}}}/spring.log}"/>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder">
<customFields>{"app_name":"${APP_NAME:-N/A}","app_version":"${APP_VERSION:-N/A}","hostname":"${HOST:-N/A}","environment":"${environment:-${ENVIRONMENT:-N/A}}"}</customFields>
<includeContext>false</includeContext>
<timeZone>UTC</timeZone>
</encoder>
<encoder class="net.logstash.logback.encoder.LogstashAccessEncoder">
<fieldNames>
<requestHeaders>request_headers</requestHeaders>
</fieldNames>
</encoder>
<file>${LOG_FILE}</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${LOG_FILE_ROTATION:-${LOG_FILE}%d{yyyy-MM-dd}.%i}</fileNamePattern>
<maxHistory>${LOG_FILE_ROTATION_MAX_HISTORY:-1}</maxHistory>
<totalSizeCap>${LOG_FILE_ROTATION_TOTAL_SIZE_CAP:-3GB}</totalSizeCap>
<maxFileSize>${LOG_FILE_ROTATION_MAX_FILE_SIZE:-1GB}</maxFileSize>
</rollingPolicy>
</appender>
<root level="${LOG_LEVEL:-INFO}">
<appender-ref ref="CONSOLE" />
<appender-ref ref="FILE" />
</root>
</configuration>
Error:
java.lang.IllegalStateException: Logback configuration error detected:
ERROR in ch.qos.logback.core.joran.spi.Interpreter#19:29 - no applicable action for [requestHeaders], current ElementPath is [[configuration][appender][encoder][fieldNames][requestHeaders]]
The xml configuration file you provided appears to be for logback-classic (since it includes <root level=...).
Automatic logging of request headers by logstash-logback-encoder is only available for IAccessEvents logged via logback-access.
In other words, automatic logging of request headers is not available for ILoggingEvents logged via a Logger from logback-classic. However, you can manually include them when using logback-classic as described below.
Logging of request headers with logback-access
To log request headers for IAccessEvents logged via logback-access, follow the instructions for setting up logback-access for tomcat or jetty, and add the following to your logback-access.xml. (Note this is not the logback.xml file used by logback-classic)
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashAccessEncoder">
<fieldNames>
<requestHeaders>request_headers</requestHeaders>
</fieldNames>
</encoder>
</appender>
<appender-ref ref="console"/>
</configuration>
This configuration was tested using logstash-logback-encoder 5.3. Note that the xml element names are different in logstash-logback-encoder versions prior to 5.0, so ensure you are using 5.0+ with that configuration.
Logging of request headers with logback-classic
logstash-logback-encoder does not provide first-class support for logging request headers via logback-classic. However, you include them in a log event logged via a Logger by using event-specific custom fields.
For example, in a class that has access to the http request (such as a servlet filter), you could do something like this:
Map<String, String> httpHeadersMap = ...; // get http request headers as a map
LOGGER.info("request", StructuredArguments.entries(httpHeadersMap));
and configure a LogbackEncoder in your logback.xml like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration>
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder class="net.logstash.logback.encoder.LogstashEncoder"/>
</appender>
<root level="info">
<appender-ref ref="console" />
</root>
</configuration>

Must multiple Logback PropertyDefiner implementations be created to pull in multiple properties?

I am able to use a Logback PropertyDefiner to access a single property from a logback.xml configuration file. If I have 3 properties to access, I am currently using 3 separate implementations of PropertyDefiner (one for each property).
Is there a way to access multiple properties from a single PropertyDefiner implementation? Or perhaps there is another interface that supports multiple properties?
I want to be be able to use properties to plugin different values, based on environment (dev, ist, uat, perf, prod) for various logging configurations (context name, log levels, appender file names, file sizes, etc.).
I found this question, which is similar, but did not answer the question of how to access multiple properties.
Create a PropertyDefiner implementation class. The PropertyDefinerBase implementation is already provided.
package foo.bar;
import java.util.HashMap;
import java.util.Map;
import ch.qos.logback.core.PropertyDefinerBase;
public class LoggingPropertiesDefiner extends PropertyDefinerBase {
private static Map<String, String> properties = new HashMap<>();
static {
properties.put("encoderPattern", "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger - %message%n");
properties.put("maxFileSize", "50MB");
properties.put("rootLogLevel", "INFO");
}
private String propertyLookupKey;
public void setPropertyLookupKey(String propertyLookupKey) {
this.propertyLookupKey = propertyLookupKey;
}
#Override
public String getPropertyValue() {
//TODO In the real world, get properties from a properties loader.
return properties.get(propertyLookupKey);
}
}
In the logback.xml, use the same PropertyDefiner class for each property. Provide a different lookup key for each:
<define name="encoderPattern" class="foo.bar.LoggingPropertiesDefiner">
<propertyLookupKey>encoderPattern</propertyLookupKey>
</define>
<define name="maxFileSize" class="foo.bar.LoggingPropertiesDefiner">
<propertyLookupKey>maxFileSize</propertyLookupKey>
</define>
<define name="rootLogLevel" class="foo.bar.LoggingPropertiesDefiner">
<propertyLookupKey>rootLogLevel</propertyLookupKey>
</define>
Reference the property names in the logback.xml:
<root level="${rootLogLevel}">
<appender-ref ref="FILE"/>
</root>
You could use the property resource support from logback
logback.properties
mode=prod
logback.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true">
<property resource="logback.properties" />
<if condition='property("mode").equals("prod")'>
<then>
<include file="logback-prod.xml" />
</then>
</if>
<if condition='property("mode").equals("dev")'>
<then>
<include resource="logback-dev.xml" />
</then>
</if>
</configuration>
logback-prod.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--Daily rolling file appender -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${MYAPP_HOME}/myApp.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>myApp.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>2</MaxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern>
</layout>
</appender>
<root level="ERROR">
<appender-ref ref="file" />
</root>
</configuration>
logback-dev.xml
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!--Daily rolling file appender -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>${MYAPP_HOME}/myApp.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>myApp.%d{yyyy-MM-dd}.log</FileNamePattern>
<MaxHistory>2</MaxHistory>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</Pattern>
</layout>
</appender>
<root level="TRACE">
<appender-ref ref="file" />
</root>
</configuration>
More detailed explaination here.
Does that help to resolve your problem?

Failed to use log4crc configuration file

I am trying to use log4c for my C application logging. For implementing rolling policy, I used log4c rolling file APIs. I understood from Log4C developers guide that the rolling policy could be achieved by editing the configuration file (log4crc). I tried editing the appender name to a log file path in the configuration file. But the application run without logging. Can anyone please tell me how to implement rolling log mechanism using log4c?
Please see my helloworld application sample and the configuration file below:
#include<stdio.h>
#include"log4c.h"
int main(int argc, char** argv)
{
int rc = 0;
log4c_category_t* mycat = NULL;
if (log4c_init()){
printf("log4c_init() failed");
rc = 1;
}else{
mycat = log4c_category_get("log4c.examples.helloworld");
log4c_category_log(mycat, LOG4C_PRIORITY_ERROR, "Hello World!");
/* Explicitly call the log4c cleanup routine */
if ( log4c_fini()){
printf("log4c_fini() failed");
}
}
return 0;
}
The configuration file looks as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE log4c SYSTEM "">
<log4c version="1.2.3">
<config>
<bufsize>0</bufsize>
<debug level="2"/>
<nocleanup>0</nocleanup>
<reread>1</reread>
</config>
<category name="root" priority="notice"/>
<category name="six13log.log" priority="error" appender="stdout" />
<rollingpolicy name="myrollingpolicy" type="sizewin" maxsize="1024" maxnum="10" />
<appender name="myrollingfileappender" type="rollingfile" logdir="." prefix="myprefix" layout="dated" rollingpolicy="myrollingpolicy" />
<appender name="stdout" type="stream" layout="basic"/>
<appender name="stderr" type="stream" layout="dated"/>
<appender name="syslog" type="syslog" layout="basic"/>
<appender name="s13file" type="s13_file" layout="basic"/>
<appender name="plain_stderr" type="s13_stderr" layout="none"/>
<appender name="cat_stderr" type="s13_stderr" layout="catlayout"/>
<appender name="xml_stderr" type="s13_stderr" layout="xmllayout"/>
<appender name="user_stderr" type="s13_stderr" layout="userlayout"/>
<layout name="basic" type="basic"/>
<layout name="dated" type="dated"/>
<layout name="catlayout" type="s13_cat"/>
<layout name="xmllayout" type="s13_xml"/>
<layout name="none" type="s13_none"/>
<layout name="userlayout" type="s13_userloc"/>
<category name="six13log.log.app.application2" priority="debug" appender="cat_stderr" />
<category name="six13log.log.app.application3" priority="debug" appender="user_stderr" />
<category name="six13log.log.app" priority="debug" appender="myrollingfileappender" />
<category name="log4c.examples.helloworld" priority="debug" appender="stdout"/>
<category name="log4c.examples.helloworld" priority="debug" appender="/home .. /..filename.txt"/>
</log4c>
I edited the last two lines in the configuration file for logging.
Please let me know what is wrong with my log4crc configuration file and how I can use configuration file to implement logging without using log4c rolling policy apis?
I am also new to log4c. But what I understand from your log4c configuration file
you have category name "log4c.examples.helloworld" twice. So when you write log4c_category_get("log4c.examples.helloworld") it is going to check from CRC file and will get appender name.
Corresponding to log4c.examples.helloworld the appender names are "stdout" and "/home .. /..filename.txt". First one is proper as it will give output to screen. The last one is improper. Do not specify file path there. Put name/ string that will correspoond to appender name. And then in appender name you have logdir value where you can specify the directory where your file will get created.
Check whether your log4crc file is included in the helloworld directory
Removing the version number completely works for me:
Change
<log4c version="1.2.3">
to
<log4c>

sl4j/logback under weblogic

I'm trying to configure sl4j/logback under Weblogic12.
I deploy ear file, which has war file, which has WEB-INF\classes\logback.xml
Here is the config:
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
My code to log :
private static final Logger logger = LoggerFactory.getLogger(FrontEndServlet.class);
//......
logger.info("info test");
logger.debug("debug test");
logger.error("error test");
What I see in the standart output is :
ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
INFO: info test
ьрщ 14, 2012 5:09:29 PM .....FrontEndServlet doPost
SEVERE: error test
So, it looks like config file is not picked up.
What am I doing wrong?
The problem is discussed here in detail: https://stagingthinking.wordpress.com/2012/06/02/annoying-slf4j-problem-in-weblogic-server-12c/
The exact package you need to put to the prefer-application-packages mechanism is org.slf4j, like this:
<?xml version='1.0' encoding='UTF-8'?>
<weblogic-application>
<prefer-application-packages>
<package-name>org.slf4j</package-name>
</prefer-application-packages>
</weblogic-application>
Note: Also this question is already answered, I want to add that you should also add prefer-application-resources.
Answer: Add a file called META-INF/weblogic-application.xml to your ear, containing both prefer-application-packages and prefer-application-resources!
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-application
xmlns="http://xmlns.oracle.com/weblogic/weblogic-application"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-application http://xmlns.oracle.com/weblogic/weblogic-application/1.5/weblogic-application.xsd"
version="6">
<!-- http://www.torsten-horn.de/techdocs/jee-oracleweblogic.htm -->
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
<!-- if not using prefer-application-resources you will get a warning like this: -->
<!-- Class path contains multiple SLF4J bindings -->
<!-- SLF4J: Found binding in [jar:file:/C:/wls1211/modules/org.slf4j.jdk14_1.6.1.0.jar!/org/slf4j/impl/StaticLoggerBinder.class] -->
<prefer-application-resources>
<resource-name>org/slf4j/impl/StaticLoggerBinder.class</resource-name>
</prefer-application-resources>
</weblogic-application>
The problem was - sl4j did not pick up logback and used Weblogic's slf4j-jdk logging instead. Can be fixed with Weblogic's config weblogic-application.xml, option prefer-application-packages
Alternatively or if you have problems with more than just slf4j, you could use
<wls:container-descriptor>
<wls:prefer-web-inf-classes>true</wls:prefer-web-inf-classes>
</wls:container-descriptor>
Instead of
<prefer-application-packages>
<package-name>org.slf4j.*</package-name>
</prefer-application-packages>
Source: Oracle
Environment: Weblogic 12.2.1
Logging Framework : Slf4j and Logback
Requirement : Log to a file of my choosing (per application) as well as Weblogic server logs
Using the <prefer-application-packages/> or <prefer-web-inf-classes> in weblogic.xml did not satisfy the requirement. In my testing, using one or the other tags (you can't use both) will result in the application logback.xml to be picked up and logging will go to the file defined in logback.xml. However, the typical STDOUT defintion using logback's ConsoleAppender will not log to the server logs.
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
Removing the following from weblogic.xml
<wls:prefer-application-packages>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
will result in using the bundled SLF4j binding, which in Weblogic 12.2.1, is Java Util logging. In this case, log statements will go to the server logs and not to the file definition in the application level logback.xml. In my research, it appears at one time, some version of Weblogic 12 allowed the internal SLF4j to be bound to Log4j but was removed in one of the minor releases. This was my case; I did not have the option of enabling Log4j as the primary logging Framework in Weblogic through the Admin console. I am fairly sure this wouldn't have helped me, but I did want to note it because several documents I read indicated this would be available.
After much research and fighting configuration with weblogic.xml, configuration of POM (exclusions etc) and trying to use different bindings and bridges, I was unable to achieve the logging configuration that I wanted. It appears that Weblogic's slf4j is bound to Java utility logging, for better or worse. If you choose your own implementation of slf4j and binding (in my case Logback), there is no way that I could find to route those messages to Weblogic server logs through configuration. There can only be one binding in slf4j, and although many frameworks can be routed to that one binding, (I found this diagram useful) Weblogic 12.2.1 only employs Java util logging binding, there is no way to (at the application configuration level) to wire Weblogic to use the Logback binding that you provide to log to its server logs. There might be some way to use log4j and bridges to accomplish this, but for me that's entirely too much bloat and configuration to accomplish a simple logging task.
Giving up on trying to conquer this by configuration, I decided to simply write my own logback appender that translates a logging event into a JUL logging event. I replaced the standard STDOUT definition seen in many Logback examples with my own implementation of Logback's AppenderBase. At this point I can now log using per application logging configuration and also log to the Weblogic Server log.
Relevant POM Dependencies:
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.25</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-classic -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/ch.qos.logback/logback-core -->
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.3</version>
</dependency>
weblogic.xml (Note here that Hibernate comes with JbossLogging which will bridge to slf4j automatically)
<?xml version="1.0" encoding="UTF-8"?>
<weblogic-web-app xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/2.0/weblogic-web-app.xsd">
<jsp-descriptor>
<keepgenerated>true</keepgenerated>
<debug>true</debug>
</jsp-descriptor>
<context-root>YourContextRoot</context-root>
<wls:container-descriptor>
<wls:prefer-application-packages>
<wls:package-name>ch.qos.logback.*</wls:package-name>
<wls:package-name>org.jboss.logging.*</wls:package-name>
<wls:package-name>org.slf4j.*</wls:package-name>
</wls:prefer-application-packages>
<wls:prefer-application-resources>
<wls:resource-name>org/slf4j/impl/StaticLoggerBinder.class</wls:resource-name>
</wls:prefer-application-resources>
</wls:container-descriptor>
Logback AppenderBase implementation
import java.util.logging.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.AppenderBase;
public class WeblogicAppender extends AppenderBase<ILoggingEvent> {
private final Logger logger = Logger.getLogger(WeblogicAppender.class.getName());
ILoggingEvent event = null;
#Override
protected void append(ILoggingEvent event) {
this.event = event;
logger.log(getJULLevel(), event.getFormattedMessage());
}
private java.util.logging.Level getJULLevel() {
if (this.event == null) {
return java.util.logging.Level.SEVERE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.ALL) {
return java.util.logging.Level.ALL;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.DEBUG) {
return java.util.logging.Level.FINE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.ERROR) {
return java.util.logging.Level.SEVERE;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.INFO) {
return java.util.logging.Level.INFO;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.TRACE) {
return java.util.logging.Level.FINEST;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.WARN) {
return java.util.logging.Level.WARNING;
} else if (this.event.getLevel() == ch.qos.logback.classic.Level.OFF) {
return java.util.logging.Level.OFF;
} else {
return java.util.logging.Level.INFO;
}
}
}
Logback.xml configuration
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="com.your.package.WeblogicAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger: LineNumber:%L - %message%n</pattern>
</encoder>
</appender>
<appender name="FILE"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>yourlog.log
</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>yourlog.%d{yyyy-MM-dd}.%i.log
</fileNamePattern>
<maxFileSize>25MB</maxFileSize>
<maxHistory>60</maxHistory>
<totalSizeCap>10GB</totalSizeCap>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger: LineNumber:%L - %message%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="STDOUT" />
<appender-ref ref="FILE" />
</root>
</configuration>
Hopefully I can save others some of the pain that I went through trying to get this working the way I wanted.