tail logback log files with log level coloring in linux server
I don't know what file formats are supported by multitail per default but you can easily create a new color scheme for logback (see multitail.conf). I added the current log4j colorscheme as an example:
colorscheme:log4j
cs_re:magenta::
cs_re:magenta:/
cs_re:blue:^[0-9]*-[0-9]*-[0-9]* [0-9]*:[0-9]*:[0-9]*,[0-9]*
cs_re_s:blue,,bold:^[^ ]* *[^,]*,[^ ]* *[0-9]* *(DEBUG) *[^ ]* [^ ]* *(.*)$
cs_re_s:green:^[^ ]* *[^,]*,[0-9]* *[0-9]* *(INFO) *[^ ]* [^ ]* *(.*)$
cs_re_s:yellow:^[^ ]* *[^,]*,[0-9]* *[0-9]* *(WARN) *[^ ]* [^ ]* *(.*)$
cs_re_s:red:^[^ ]* *[^,]*,[0-9]* *[0-9]* *(ERROR) *[^ ]* [^ ]* *(.*)$
cs_re_s:red,,bold:^[^ ]* *[^,]*,[0-9]* *[0-9]* *(FATAL) *[^ ]* [^ ]* *(.*)$
cs_re_s:white,,bold:^[^ ]* *[^,]*,[0-9]* *[0-9]* *[A-Z]* *(.*)
Tail multiple files shown by separate colors?
This will print the output in two different colors depending on which log file it comes from:
tail -f log1 log2 | awk $'/==> log1/{print "\033[0m\033[1;33;40m";} /==> log2/{print "\033[0m\033[1;35;40m";} 1'
Update by Elliot Chance: Thats the start I needed, here was the working version:
tail -f /var/log/apache2/tv7r9r3falz0_error.log protected/runtime/application.log | awk '/==> /{print "\033[0m\033[1;36;40m";} /==> p/{print "\033[0m\033[1;33;40m";} {print $0}'
SLF4J-Logback : Multiple Pattern based on Log Level
In the appender config, set prudent to true. This will allow multiple appenders to write to the same file.
Webshpere and QOS logback: log-files are locked for rolling
This article does help me - http://logback.qos.ch/manual/jmxConfig.html
although we do not use any JMXConfigurators in our apps ...
So i added in web.xml
<listener>
<listener-class>ru.fns.commonex.listener.CleanUpServletContextListener</listener-class>
</listener>
Listener has next code:
@Override
public void contextDestroyed(ServletContextEvent sce) {
log.debug("contextDestroyed({}) called.", sce);
deRegisterLog();
}
/**
* Avoiding memory leaks
*
* If your application is deployed in a web-server or an application server,
* the registration of an JMXConfigurator instance creates a reference from the system class loader
* into your application which will prevent it from being garbage collected when it is stopped or re-deployed,
* resulting in a severe memory leak.
*
* Thus, unless your application is a standalone Java application,
* you MUST unregister the JMXConfigurator instance from the JVM's Mbeans server.
* Invoking the reset() method of the appropriate LoggerContext will automatically unregister any
* JMXConfigurator instance. A good place to reset the logger context is in the contextDestroyed()
* method of a javax.servlet.ServletContextListener.
*/
private void deRegisterLog() {
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
log.info("Trying to stop logger factory {}", lc);
if (lc != null) {
lc.stop();
}
}
Is possible to change the forecolor of log4j?
Check this resource : http://marc.info/?l=log4j-user&m=120574713010072
Tail multiple files shown by separate colors?
This will print the output in two different colors depending on which log file it comes from:
tail -f log1 log2 | awk $'/==> log1/{print "\033[0m\033[1;33;40m";} /==> log2/{print "\033[0m\033[1;35;40m";} 1'
Update by Elliot Chance: Thats the start I needed, here was the working version:
tail -f /var/log/apache2/tv7r9r3falz0_error.log protected/runtime/application.log | awk '/==> /{print "\033[0m\033[1;36;40m";} /==> p/{print "\033[0m\033[1;33;40m";} {print $0}'
Java Log Viewer
You didn't mention an OS, so I'll mention this though it is only on Windows.
Bare Metal Software makes a product called BareTail that has a nice interface and works well. They have a free version with a startup nag screen, a licensed version with no nag, and a pro version with additional features. It has configurable highlighting based on matching lines against keywords.
They also have a BareGrep product too, which provides similar grep capabilities. Both are excellent and very stable and better than anything I've seen on Windows. I liked them so much I bought the bundle with both pro versions for $50.
Related Topics
File/Directory Permissions Trailing + ( Drwxr-Xr-X+ )
Changing File Permissions Linux
Best Linux Filesystem Filter Option
Socket Programming Send() Return Value
"Nothing to Commit (Working Directory Clean)" When a Folder Has Been Added
Catch Signal in Bash But Don't Finish Currently Running Command
Move Cursor on Middle Button Paste in Sublime Text 3
List Files That Are in Directory1 But Not in Directory2 and Vice Versa
Inter-Module Communication in Linux Kernel
Caputre Opengl Window in X11 with Fast Framerate - Possible
How to Connect to Sftp Using Linux Command from Perl
Linux Shell Kill Signal Sigkill && Kill
How to Prevent Remote Branch Deletion in Git Without Using Gitolite
Understanding The Netstat Output
How to Get Awk to Print Without White Space
Print The Lines Between Two Dates from The Log Using Shell Command in Linux