Java log in plain text
Asked Answered
R

1

12

I redirected Java Logger to log in file using following code:

Handler handler = new FileHandler("test.log", LOG_SIZE, LOG_ROTATION_COUNT);
Logger.getLogger("").addHandler(handler);

but it logs in XML format. I want to be exactly like output (i.e. plain text). How can I do that?

Rectitude answered 6/5, 2012 at 8:17 Comment(0)
E
14

You need to set a Formatter on your Handler. Either create your own or use the SimpleFormatter

Exequies answered 6/5, 2012 at 8:22 Comment(1)
handler.setFormatter(new SimpleFormatter());Rectitude

© 2022 - 2024 — McMap. All rights reserved.