aspose file tools*
The moose likes Java in General and the fly likes Subtle, subtle, little Log4j difficulty Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Subtle, subtle, little Log4j difficulty" Watch "Subtle, subtle, little Log4j difficulty" New topic
Author

Subtle, subtle, little Log4j difficulty

Suz Reiner
Greenhorn

Joined: Feb 28, 2011
Posts: 4
I have a custom logger and a log4j.xml combination that, I hoped would send output to a specified persistent file. However, the content is being created and logged to the console instead. I'm not sure why (considering log4j is creating the intended log file). Clearly I'm missing a step. Can someone take a peak and clue me in? The code snippets are below:


private static final Logger logger = LoggerFactory.getLogger("DailyRoll");
logger.info(“text to add... report some stuff”);


<appender name="stickyBuns" class="org.apache.log4j.DailyRollingFileAppender">
<param name="file" value="daily.log" />
<param name="datePattern" value="'.'yyyy-MM-dd" />
<param name="append" value="false" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d [%t] %-5p %C{6} (%F:%L) - %m%n"/>
</layout>
<filter class="org.apache.log4j.varia.LevelRangeFilter">
<param name="LevelMin" value="DEBUG"/>
<param name="LevelMax" value="INFO"/>
</filter>
</appender>

<logger name="DailyRoll " additivity="false" >
<level value="info" />
<appender-ref ref="stickyBuns"/>
</logger>



Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

In [logger name="DailyRoll "], is the space a typo ? I don't know if log4j ignores it or not, but it's worth removing it.


[My Blog]
All roads lead to JavaRanch
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3775

And welcome to CodeRanch, Suz Reiner


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Suz Reiner
Greenhorn

Joined: Feb 28, 2011
Posts: 4
Christophe Verré wrote:In [logger name="DailyRoll "], is the space a typo ? I don't know if log4j ignores it or not, but it's worth removing it.


Yep, the space is a typo (I changed the names to protect the innocent... from public exposure ).

Thank you for taking a look.

And thank you for the warm welcome, Vijitha Kumara.
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

How did you call your log4j property file, and where did you put it ?
Suz Reiner
Greenhorn

Joined: Feb 28, 2011
Posts: 4
Christophe Verré wrote:How did you call your log4j property file, and where did you put it ?


I am using a log4j.xml file placed within reach of my package. So, in eclipse it would be located at: /src/log4j.xml. Log4j is creating all the log files specified by the appenders I have defined. And, data is being written to those log files with the exception of my custom logger/appender definition (despite the file having been created by log4j).

It is curious. I thought I was having a conflict between jars somewhere but I ran through my environment to root-out potential conflicts. I think I have cleared them but still I'm stubbing my toes and smiling about it.

Suz
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87

What is the version of log4j that you are using ?
prem pillai
Ranch Hand

Joined: Nov 02, 2007
Posts: 87


Log4j is raising the below warnig for your configuration



As mentioned by Christophe Verré, that space in the logger name is the problem. log4j does not ingore it. I have removed the space and tried ..its logging correctly to the log file.

Do you have a console appender configured in your xml? That may be the reason why log statements are going to the console.
Suz Reiner
Greenhorn

Joined: Feb 28, 2011
Posts: 4
I thought those who replied might like an update (so often missing from discussions). I located the source of my problem. It is a package conflict, after all. It would appear a vendor decided it would be a great idea to repackage all sorts of common/utility libraries with new names. They added a few folders to the base structure and TA-DAH... no-one's the wiser that name conflicts and package hell is afoot.... NOT!

Now... to figure a way isolate those monsters. Anyone have experience with this sort of suffering?

Suz
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Subtle, subtle, little Log4j difficulty
 
Similar Threads
How to supress SQL Queries in log file
log4j not logging
struts 2 and log4j
DailyRollingFileAppender & Servlets with Tomcat
how to disable the log