You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-user@logging.apache.org by Michael Coughlan <mi...@FXALL.com> on 2004/01/23 15:30:51 UTC

log4j writing to standard out

How can I get log4j to write to standard out?

I can't seem to find the proper FileOutputStream Class to initiate the WriterAppender that would display to the screen.

Sorry that this is such a basic Java lang question. Below is the Hello World program that I have working.

TIA,
MPC

public class TestLogger {
	static Logger myLogger = Logger.getLogger("TestLogger");
	
	public static void main(String[] args) {
		File myFile = null; 
		FileOutputStream myFileOS = null;
		PatternLayout myLayout = null;
		WriterAppender myAppender = null;
		
		System.out.println("Writing to file...");
		try {
		    myFile = new File("foo.out");
			myFileOS = new FileOutputStream (myFile);
		}catch (Exception e) {
			System.out.println(e.toString());
		}
		myLayout = new PatternLayout("%m%n");
		myAppender = new WriterAppender(myLayout, myFileOS);
		myLogger.addAppender(myAppender);
		myLogger.setLevel(Level.DEBUG);
		myLogger.debug("Hello World with a patternLayout");
	}
} 

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-user-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-user-help@logging.apache.org