Is there a way how we can capture all the console messages to a file that are coming from different applications in linux.
-
Define 'different applications'. Shell is an application, do you want to capture command prompt too?– gronostajJun 26, 2015 at 21:31
-
I am working on a embedded linux device and will have applications like multimedia, network or user apps that will keep printing their logs on to console and I want to redirect or have copy of all the logs that come on to console into a file.– ReddyJun 26, 2015 at 23:02
Add a comment
|
1 Answer
in /etc/syslog.conf or /etc/rsyslog.conf add something like below
usually syslog or rsyslog.
*.* -/var/log/allmessages
more advanced options available
# => all acpid messages for debuging (uncomment if needed):
if ($programname == 'acpid' or $syslogtag == '[acpid]:') then \
-/var/log/acpid
Using rsyslog you can even log to mysql database.
This can be dangerous as you can fill your hard drive/storage and crash your OS if you don't delete them at some point.
-
I already tried with syslog.conf change but it did not work for me. Might be due to busy box version of syslogd do not have that support. Also I tried with below which did not work, # Log all writes to /dev/console to a separate file. console.* /var/log/console.log– ReddyJul 2, 2015 at 18:35
-
@Reddy Did you add your rule at the very top of the syslog.conf or the bottom? If you added to the end no messages will reach that point. Jul 5, 2015 at 14:30
-
I have added it at the top of file. kern.debug /logs/kernel.log . /logs/sys.log But its not working. I did not see any kernel.log but I can see logs in sys.log which will only contain logs from different modules but nothing from kernel or console.– ReddyJul 6, 2015 at 20:26
-
using rsyslogd instead syslogd solved the problem for me. Due to some reason syslogd was not working as per the rules defined.– ReddyOct 6, 2015 at 14:20