Search code examples
javaswingloggingfile-iojtextarea

how to write everything from jtextarea to file in real time. it is something like log all info displayed into log filefile


I have no code yet I just looking for possible solutions. I will have jtextarea to output information with textarea.append and at the same time I will need to write the same string to the some kind of log file.is it possible to use logging api? I have an option to create method with textarea.append and write to file the same string but it seems to me too messy. Thank you


Solution

  • Yes, this should not be a problem. You can create a custom appender that writes to the TextArea. To only challenge here is how to get a reference to the TextArea. Of course you could have some static method that returns this reference but a cleaner solution might be to use Markers.