So, I'm using apache commons logging because I'm also using PDFBox, and I just want to be consistent. I wanted to set this up in a few minutes so I could use the log entries to debug the issue in my application.
The problem is, my commons-logging.properties file is never detected. None of my configuration settings are detected. I can't change the logging level or do anything. All I get is my info entries, in the default format.
I'm using a maven-built project, and the file is in the root of my resources directory. Everything else in that directory is detectable on the classpath, just not this aparently.
Here is my pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.pilotfish</groupId>
<artifactId>PDFViewer</artifactId>
<version>1.0</version>
<properties>
<apache.commons.io.version>2.4</apache.commons.io.version>
<apache.commons.logging.version>1.2</apache.commons.logging.version>
<apache.fontbox.version>1.8.11</apache.fontbox.version>
<apache.pdfbox.version>1.8.11</apache.pdfbox.version>
<java.version>1.7</java.version>
<maven.assembly.plugin.version>2.5.5</maven.assembly.plugin.version>
<maven.compiler.plugin.version>3.1</maven.compiler.plugin.version>
<maven.jar.plugin.version>2.6</maven.jar.plugin.version>
<maven.source.plugin.version>3.0.0</maven.source.plugin.version>
</properties>
<dependencies>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${apache.commons.io.version}</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>${apache.commons.logging.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>fontbox</artifactId>
<version>${apache.fontbox.version}</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>${apache.pdfbox.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>${maven.assembly.plugin.version}</version>
<configuration>
<archive>
<manifest>
<mainClass>com.pilotfish.eip.modules.pdfviewer.Main</mainClass>
</manifest>
</archive>
<descriptors>
<descriptor>src/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>${maven.source.plugin.version}</version>
<configuration>
<outputDirectory>${project.build.directory}/classes/source/</outputDirectory>
</configuration>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Here is my commons-logging.properties file.
# Commons Logging Properties
# Doesn't seem to work... so annoying
org.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger
# JDK Handlers
handlers=java.util.logging.ConsoleHander
# Default log level
.level=DEBUG
# Log Formatter
java.util.logging.ConsoleHander.formatter=com.pilotfish.eip.modules.pdfviewer.log.LogFormatter
.formatter=com.pilotfish.eip.modules.pdfviewer.log.LogFormatter
I'm just trying to do some simple stuff here. I don't care about anything complicated, I just want my debug statements to work. It's not right that this won't be detected.
Thanks in advance.
You must specify where the logfile is at with a command line parameter:
-Djava.util.logging.config.file=/absolute/path/to/your/config/file/commons-logging.properties MyClass