Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Subtle, subtle, little Log4j difficulty

 
Suz Reiner
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Vijitha Kumara
Bartender
Posts: 3908
9
Chrome Fedora Hibernate
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to CodeRanch, Suz Reiner
 
Suz Reiner
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How did you call your log4j property file, and where did you put it ?
 
Suz Reiner
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 87
Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the version of log4j that you are using ?
 
prem pillai
Ranch Hand
Posts: 87
Java Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic