[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Log4j WriterAppender in Java

Posted on 2009-02-24
7
Medium Priority
?
1,244 Views
Last Modified: 2013-11-23
Hello,
Im using a WriterAppender to log to a file, but It will not display the time of each log... I've included the appropriate properties in the log4j.properties for that to work... When i switch over to a RollingFileAppender it works fine...

Also im getting a
log4j:ERROR No output stream or file set for the appender named [C:\temp\Log.log].
However the error log is still created in that file with the information that I need... The error msg is annoying so I would like to get rid of it... Attached is my code from the log4j.properties file
log4j.appender.myWriterAppender=org.apache.log4j.WriterAppender
log4j.appender.myWriterAppender.Name=C:\\temp\\Log.log
log4j.appender.myWriterAppender.layout=org.apache.log4j.PatternLayout
log4j.appender.myWriterAppender.layout.ConversionPattern=[%d{ISO8601}] %5p: %m%n
 
the last line seems to be ignored...

Open in new window

0
Comment
Question by:Squadless
  • 4
  • 3
7 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 2000 total points
ID: 23723419
>>log4j.appender.myWriterAppender.Name=C:\\temp\\Log.log

should be

log4j.appender.myWriterAppender.file=C:/temp/Log.log
0
 
LVL 1

Author Comment

by:Squadless
ID: 23723485
I changed it, getting
log4j:WARN No such property [file] in org.apache.log4j.WriterAppender.
log4j:ERROR No output stream or file set for the appender named [myWriterAppender].
log4j:WARN No such property [file] in org.apache.log4j.WriterAppender.
 
log4j:ERROR No output stream or file set for the appender named [myWriterAppender].

Open in new window

0
 
LVL 1

Author Comment

by:Squadless
ID: 23723496
Is there a place where i can see what the tag properties should be... im sure im just missing 1 damn word which woudl solve my issue
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Author Comment

by:Squadless
ID: 23723738
eh i give up... using fileappender ;)
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23723762
Sorry - was thinking it was a FileAppender. What are you attaching to your WriterAppender?
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 23723796
afaik you can't declare a WriterAppender in config - there would be no way of specifying the stream or writer to attach to
0
 
LVL 1

Author Comment

by:Squadless
ID: 23723917
Yeah, figured thats what the problem, was... Im just going to use a FileAppender.much simpler

Thanks!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month18 days, 10 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question