Reading standard `logger` logs

How to read logs produced from logger, i.e. by logger_std_h or logger_disk_log_h ?

Ideally, what I want is some interface like the one in wrar_logger_reader, but it seems that it’s only working for disk_log, not logger:

1> wrap_log_reader:open("_log/my.log").
{error, {not_a_log_file,"_log/my.log.1"}}

_log/my.log.1, _log/my.log.idx and _log/my.log.siz exist and are logger_disk_log_h files. _log/my.log.1 is empty but it seems that its being ignored for some reason.

Is there any way to make those 2 compatible or is there an alternative for logger?

The logs output by logger_std_h with the default formatter are not meant to be parseable by tools, but by humans looking at the logs. If you want to parse the logs afterwards you need to use a formatter that allows for parsing, for example by printing the Erlang term representation of the log message, or encode the log message to json.

I understand part about parsing, but reading the file is the problem in the first place.

I don’t need parsing interface, just some stuff to read the log that’s possibly rotated and/or compressed.

Ideally, I’d like an interface like this:

{ok, Log} = logger_reader:open(LoggerId),
%% Working like this is a regular file
file:read_line(Log)

rb has something similar, but not working with logger.

Ah, now I understand. There is no such tool that I know of. The format should be the same as for logrotate so maybe there is some tool for it that can be used here as well?

1 Like