In the first place, sorry for several different questions placed in
one letter. I know it's something wearily to answer a list of
questions.
I tried using error_logger as a tool for handling error reports and
I've came across some oddities:
#1. Is there a way to set SASL options (I'm about sasl_error_logger,
errlog_type etc) from the Erlang code at runtime without using a
.config file + the "-config" argument? I just want to give an end user
only one config file to edit and use values from that to setup SASL.
#2. The following is from the "Programming Erlang":
--[Beginning of quote]-------------------------------------------------
The next configuration file lists error reports in the shell, and a copy of
everything reported in the shell is also made to a file:
%% single text file - minimal tty
[{sasl, [
%% All reports go to this file
{sasl_error_logger, {file, "/home/joe/error_logs/THELOG" }}
]}]."
--[End of quote]-------------------------------------------------
I replaced the path to just "THELOG" and then run the shell:
--[Beginning of erl session]-------------------------------------------------
erl -boot start_sasl -config elog2.config
Erlang (BEAM) emulator version 5.6.3 [source] [smp:2]
[async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.6.3 (abort with ^G)
1> error_logger:error_msg("foobar~n").
ok
=ERROR REPORT==== 10-Oct-2008::03:19:38 ===
foobar
2> error_logger:error_report("foobar\n").
=ERROR REPORT==== 10-Oct-2008::03:21:05 ===
foobar
ok
3>
User switch command
--> q
--[End of erl session]-------------------------------------------------
But after all, THELOG doesn't contain any string related to my
foobar-errors! Just only progress reports! Why does this happen?
#3. If I decide to use rotating of logs, those logs will be written in
binary format. What are the benefits of using binary format for
storing logs? Is there possibility to force Erlang to use plain text
files instead of binary ones?
#4. What is the "index" file for?
#5. Quote from Programming Erlang:
--[Beginning of quote]-------------------------------------------------
In a production environment, we are really interested only in errors and
not progress or information reports, so we tell the error logger to report
only errors. Without this setting, the system might get swamped with
information and progress reports.
Download elog4.config
%% rotating log and errors
[{sasl, [
%% minimise shell error logging
{sasl_error_logger, false},
%% only report errors
{errlog_type, error},
%% define the parameters of the rotating log
%% the log file directory
{error_logger_mf_dir,"/home/joe/error_logs" },
%% # bytes per logfile
{error_logger_mf_maxbytes,10485760}, % 10 MB
%% maximum number of
{error_logger_mf_maxfiles, 10}
]}].
--[End of quote]-------------------------------------------------
But using this config I see some progress reports:
3> rb:list().
No Type Process Date Time
== ==== ======= ==== ====
6 progress <0.30.0> 2008-10-10 03:39:59
5 progress <0.30.0> 2008-10-10 03:39:59
4 progress <0.30.0> 2008-10-10 03:39:59
3 progress <0.30.0> 2008-10-10 03:39:59
2 progress <0.23.0> 2008-10-10 03:39:59
1 error <0.24.0> 2008-10-10 03:40:20
ok
What is wrong?
--
Sergey.
P.S. Sorry for the possible English mistakes in my letter =)
_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://www.erlang.org/mailman/listinfo/erlang-questions
Hello.
In the first place, sorry for several different questions placed in
one letter. I know it's something wearily to answer a list of
questions.
I tried using error_logger as a tool for handling error reports and
I've came across some oddities:
#1. Is there a way to set SASL options (I'm about sasl_error_logger,
errlog_type etc) from the Erlang code at runtime without using a
.config file + the "-config" argument?
I just want to give an end user
only one config file to edit and use values from that to setup SASL.
The following error logger event handlers are defined in the SASL application.
#3. If I decide to use rotating of logs, those logs will be written in
binary format. What are the benefits of using binary format for
storing logs?
Is there possibility to force Erlang to use plain text
files instead of binary ones?
#4. What is the "index" file for?
P.S. Sorry for the possible English mistakes in my letter =)
I guess application:set_env(App, Par, Val) is what you're after?
However, the function comes with a big fat warning:
"Use this function only if you know what you are doing, that is, on your
own applications. It is very application and configuration parameter
dependent when and how often the value is read by the application, and
careless use of this function may put the application in a weird,
inconsistent, and malfunctioning state."
(http://www.erlang.org/doc/apps/kernel/application.html)
Especially with things like the error logger, the value is expected
to be present from the beginning, and the warning is particularly
relevant.
If you don't want to mess with a config file, you can add the
parameters to the command line, using -App Par Val constructs.
Remember to escape special characters and omit spaces if you
want to declare complex terms this way. It's easy with simple
values, like
erl -sasl error_logger_mf_maxbytes 100000
BR,
Ulf W
Edwin Fine, Ulf Wiger, thanks for your detailed answers! They were
very-very helpful to me!
Trying all your suggestions in practice took some time, but now I know
what to do with logging and what to read in the following.
--
Sergey