EzDevInfo.com

syslog interview questions

Top syslog frequently asked interview questions

Does Syslog really have a 1KB message limit?

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)

Adding year in the syslog message (linux)


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)

Advertisements

Syslog messages show up as "Unknown" when I use Python's logging.handlers.SysLogHandler

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)

How to configure logging to syslog in python?

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)

syslog_r for Linux?

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)

Need suggestion for SysLog with Node.js

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)

How do you read a segfault kernel log message

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:

  1. 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

  2. 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)

Multiline log records in syslog

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)

Reading syslog output on a Mac

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)

Open Source Syslog Daemon for Windows [closed]

Can anyone recommend an open source Syslog Daemon for Windows (specifically Windows 2008 64bit).

Thanks


Source: (StackOverflow)

Redirect C++ std::clog to syslog on Unix

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)

How to setup SysLogHandler with Django 1.3 logging dictionary configuration

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)

Are gnu syslog(), openlog() and closelog() thread-safe?

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)

What is the most modern way to log to syslog using a java.util.logging handler?

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)

Redirecting standard output to syslog

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)