siberian-fast-food / alogger

Simply the best logging framework for Erlang
Apache License 2.0
50 stars 16 forks source link

Add an ability to have several loggers from the same alog_* module #32

Closed w495 closed 11 years ago

w495 commented 12 years ago

I need to write different log levels messages in different log files. What should I do? It'ill be nice to use something like this:

[
    {alog, [
            {enabled_loggers,[alog_disk_log1,alog_disk_log2,alog_disk_log3]},
            {install_error_logger_handler, true},
            {flows, [
                {{mod, ['_']}, {'=<', debug}, [alog_disk_log1]},
                {{mod, ['_']}, {'=<', warning}, [alog_disk_log2]},
                {{mod, [alog_examples]}, {'=<', debug}, [alog_disk_log3]}
            ]},
            {alog_disk_log1, [
                {module, alog_disk_log},
                {name, alog_disk_log1},
                {file, "priv/logs/alog_disk_log1.log"},
                {format, external}
            ]},
            {alog_disk_log2, [
                {module, alog_disk_log},
                {name, alog_disk_log2},
                {file, "priv/logs/alog_disk_log2.log"},
                {format, external}
            ]}
            {alog_disk_log3, [
                {module, alog_disk_log},
                {name, alog_disk_log3},
                {file, "priv/logs/alog_disk_log2.log"},
                {format, external}
            ]}
    ]}
].

Is there way to do this with current version of alogger?

ates commented 12 years ago

Alog is dead, isn't? Use lager instead.

2garryn commented 12 years ago

hm.. I think ates is right. Now we don't commit to alogger

w495 commented 12 years ago

А гуглогруппах говорили, что не умрет. ((( It is very sad! Lager cannot add handlers at runtime.

Cy6erBr4in commented 11 years ago

Hi,

I'm thinking about resumption of development, and this particular feature is in my TODO (moreover, I heard that this is already implemented in one of the forks, probably a private one, so I'll ask for a pull request).

Cy6erBr4in commented 11 years ago

Now it's possible, here's an example of configuration:

 {alog,
  [{enabled_loggers,
    [{access_log, alog_disk_log},
     {messages_log, alog_disk_log},
    ]},
   {flows,
    [{{mod, ['_']}, {'=<', debug}, [{{messages_log, alog_disk_log}, alog_disk_log}]},
     {{tag, ['access']}, {'=<', debug}, [{{access_log, alog_disk_log}, alog_disk_log}]},
    ]},
   {access_log,
    [{name, access_log},
     {file, "/var/log/your_node/access.log"},
     {format, external}
    ]},
   {messages_log,
    [{name, messages_log},
     {file, "/var/log/your_node/messages.log"},
     {format, external}
    ]},
  ]}

I'll update the documentation soon, so it reflects the code changes.