Setting Appender's fields in Apache's Log4J

R

Raga

Hi,

In the following code snippet (which is written to create a
FileAppender & make log4J log to that file):

import org.apache.log4j.*;

class sample
{
.....
HTMLLayout layout = new HTMLLayout();
layout.TITLE_OPTION = "DataSE Log";
String logFileName = "Log.txt";
Appender appender = new FileAppender(layout, logFileName, true);
appender.immediateFlush = false;
appender.bufferedIO = true;
appender.bufferSize = 64;
Logger logger = Logger.getLogger();
logger.addAppender(appender);
......
}

the above snippet is not inside any method. Its directly within the
class. In the above snippet, I am encountering 2 types of errors:

1. Am using the fields of the classes FileAppender & layout. The usage
seems to be wrong, because am getting the error "'synatx error on
token(s); misplaced construct(s)" & similar errors.

2. how to specify the bufferSize? Just as '64' or '64K'?


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,990
Messages
2,570,211
Members
46,796
Latest member
SteveBreed

Latest Threads

Top