• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it possible to show log in TextArea

 
mandlar suurla
Ranch Hand
Posts: 67
Debian Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am logging program with log4j and I want to show the logged information in JTextArea is it possible and if it is, is it hard to make? Or got any tutorial for it? I would like to make them both be synchronous so when information is logged then it displays it at same time in textarea.
 
Rob Spoor
Sheriff
Posts: 20837
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks just like my TextComponentAppender. Basically, what you need to do:

- extend AppenderSkeleton
- keep a reference to your text area
- implement requiresLayout to always return true - after all, it's the layout that will transform the events into strings
- implement append similar to below

 
mandlar suurla
Ranch Hand
Posts: 67
Debian Linux PHP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made before your post singleton class which writes in the same method to log and textarea, but i need to say that i used textarea object as static variable, i think is should pass by parameter.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!