syslog interview questions
Top syslog frequently asked interview questions
It seems Syslog has a 1KB message limit. Is this hardcoded into the Syslog protocol, or is this a parameter that can be set for each server?
I am hoping the article I read was out of date, so if you have any info please share.
Source: (StackOverflow)
I need to log the year in the log message generated by syslog daemon. In particular in the /var/log/secure file. Is it possible?
Here an example of normal syslog message:
Feb 16 04:06:58 HOST sshd[28573]: Accepted password for USER from SOURCE port 7269 ssh2
And I need something similar to:
Feb 16 2011 04:06:58 HOST sshd[28573]: Accepted password for USER from SOURCE port 7269 ssh2
Thanks in advance.
Source: (StackOverflow)
When I run this on my mac:
import logging.handlers
logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
syslog_address = '/var/run/syslog'
logger.addHandler(logging.handlers.SysLogHandler(syslog_address))
logger.error("What the crap?")
It shows up like this in the syslog:
Oct 18 19:02:06 nick Unknown[4294967295] <Error>: What the crap?
Why is it Unknown? Shouldn't it be smart enough to name itself after the script's name?
Source: (StackOverflow)
I can't get my head around Python's logging
module. My needs are very simple: I just want to log everything to syslog. After reading documentation I came up with this simple test script:
import logging
import logging.handlers
my_logger = logging.getLogger('MyLogger')
my_logger.setLevel(logging.DEBUG)
handler = logging.handlers.SysLogHandler()
my_logger.addHandler(handler)
my_logger.debug('this is debug')
my_logger.critical('this is critical')
But this script does not produce any log records in syslog. What's wrong?
Source: (StackOverflow)
Folks, I can't find the re-entrant version of syslog() for Linux...is there one? And if no, what do you? The obvious answer is to move logging facility into separate thread and serialise access to syslog...
Source: (StackOverflow)
I have just npm install node-syslog but it doesn't work.
I have a syslog server (IP address , and local0).
And I'm looking for a syslog module to help me post the message to syslog. But I don't know which one I should use. Please give me some suggestion. thanks.
oh.. if there is a good syslog parser (node.js), please let me know too. :)
Source: (StackOverflow)
This can be a very simple question, I'm am attempting to debug an application which generates the following segfault error in the kern.log
kernel: myapp[15514]: segfault at 794ef0 ip 080513b sp 794ef0 error 6 in myapp[8048000+24000]
Here are my questions:
Is there any documentation as to what are the diff error numbers on segfault, in this instance it is error 6, but i've seen error 4, 5
What is the meaning of the information at bf794ef0 ip 0805130b sp bf794ef0 and myapp[8048000+24000]
?
So far i was able to compile with symbols, and when i do a x 0x8048000+24000
it returns a symbol, is that the correct way of doing it? My assumptions thus far are the following:
- sp = stack pointer?
- ip = instruction pointer
- at = ????
- myapp[8048000+24000] = address of symbol?
Source: (StackOverflow)
So I've configured my Python application to log to syslog with Python's SysLogHandler, and everything works fine. Except for multi-line handling. Not that I need to emit multiline log records so badly (I do a little), but I need to be able to read Python's exceptions. I'm using Ubuntu with rsyslog 4.2.0. This is what I'm getting:
Mar 28 20:11:59 telemachos root: ERROR 'EXCEPTION'#012Traceback (most recent call last):#012 File "./test.py", line 22, in <module>#012 foo()#012 File "./test.py", line 13, in foo#012 bar()#012 File "./test.py", line 16, in bar#012 bla()#012 File "./test.py", line 19, in bla#012 raise Exception("EXCEPTION!")#012Exception: EXCEPTION!
Test code in case you need it:
import logging
from logging.handlers import SysLogHandler
logger = logging.getLogger()
logger.setLevel(logging.INFO)
syslog = SysLogHandler(address='/dev/log', facility='local0')
formatter = logging.Formatter('%(name)s: %(levelname)s %(message)r')
syslog.setFormatter(formatter)
logger.addHandler(syslog)
def foo():
bar()
def bar():
bla()
def bla():
raise Exception("EXCEPTION!")
try:
foo()
except:
logger.exception("EXCEPTION")
Source: (StackOverflow)
I have a program that was written for linux and I am trying to build and run it on my MacOS 10.5 machine. The program builds and runs without problem, however it makes many calls to syslog. I know that syslogd is running on my mac, however I can't seem to find where my syslog calls are output to.
The syslog calls are of the form
syslog (LOG_WARNING, "Log message");
Any idea where I might find my log output?
Source: (StackOverflow)
Can anyone recommend an open source Syslog Daemon for Windows (specifically Windows 2008 64bit).
Thanks
Source: (StackOverflow)
I work on Unix on a C++ program that send messages to syslog.
The current code uses the syslog system call that works like printf.
Now I would prefer to use a stream for that purpose instead, typically the built-in std::clog. But clog merely redirect output to stderr, not to syslog and that is useless for me as I also use stderr and stdout for other purposes.
I've seen in another answer that it's quite easy to redirect it to a file using rdbuf() but I see no way to apply that method to call syslog as openlog does not return a file handler I could use to tie a stream on it.
Is there another method to do that ? (looks pretty basic for unix programming) ?
Edit: I'm looking for a solution that does not use external library. What @Chris is proposing could be a good start but is still a bit vague to become the accepted answer.
Edit: using Boost.IOStreams is OK as my project already use Boost anyway.
Linking with external library is possible but is also a concern as it's GPL code. Dependencies are also a burden as they may conflict with other components, not be available on my Linux distribution, introduce third-party bugs, etc. If this is the only solution I may consider completely avoiding streams... (a pity).
Source: (StackOverflow)
I'm having no luck finding any information on setting up syslog logging with Django 1.3 dictionary configuration. The Django documents don't cover syslog and the python documentation is less than clear and doesn’t cover dictionary config at all. I've started with the following but I'm stuck on how to configure the SysLogHandler.
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'formatters': {
'verbose': {
'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
},
'simple': {
'format': '%(levelname)s %(message)s'
},
},
'handlers': {
'syslog':{
'level':'DEBUG',
'class':'logging.handlers.SysLogHandler',
'formatter': 'verbose'
},
},
'loggers': {
'django': {
'handlers':['syslog'],
'propagate': True,
'level':'INFO',
},
'myapp': {
'handlers': ['syslog'],
'propagate': True,
'level': 'DEBUG',
},
},
}
Source: (StackOverflow)
I have been searching for some time and haven't found a definitive answer yet. The only link I found till now which sheds some light on this is here.
Source: (StackOverflow)
I am specifically looking for the most up to date, modern SysLogHandler
for java.util.logging
.
I have found a few that date back to 2001 - 2003, mostly un-supported now.
I know that syslog
is a pretty static service, I am wondering before I write something myself, if there are any newer handler implementations that support the Java 1.5 and newer features.
I am not interested in any of the other logging frameworks or wrapper / proxy libraries.
I am not looking for SLF4J or any other alternative logging frameworks, as suggested in this question.
Source: (StackOverflow)
I'm planning to package OpenTibia Server for Debian. One of the things I want to do is add startup via /etc/init.d
and daemonization of the otserv
process.
Thing is, we should probably redirect output to syslog. This is usually done via the syslog()
function. Currently, the code is swarmed with:
std::cout << "Stuff to printout" << std::endl;
Is there a proper, easy to add, way to redirect standard output and standard error output into syslog without replacing every single "call" to std::cout and friends?
Source: (StackOverflow)