From: Felix Dietrich <felix.dietrich@sperrhaken.name>
To: Jean Louis <bugs@gnu.support>
Cc: Help GNU Emacs <help-gnu-emacs@gnu.org>
Subject: Re: Apache2 error messages
Date: Mon, 03 Oct 2022 17:33:28 +0200 [thread overview]
Message-ID: <871qro6hx3.fsf@sperrhaken.name> (raw)
In-Reply-To: <courier.0000000063344E16.000046C9@stw1.rcdrun.com> (Jean Louis's message of "Wed, 28 Sep 2022 16:36:31 +0300")
Hello Jean,
Jean Louis <bugs@gnu.support> writes:
> I would like myself to be able to send messages to Apache log.
>
> Now this message is appearing in error.log, but it does not appear to
> be error.
>
> Wed Sep 28 06:31:32.023427 2022] [cgi:error] [pid 5706] [client 102.83.37.37:54464] AH01215: Loading /var/www/.emacs.d/init.el (source)...: /var/www/subscribe.example.com/doi.cgi
This appears to be one of Emacsʼ startup messages. These are written to
the standard error stream.
> Never mind, I would like to send messages to error log. Is the way to
> go to use `message' function?
With ‘message’ you can write to the standard output stream, when using
Emacs with the “--script” or “--batch” command line options. Using an
Emacs Lisp file as a CGI script, I believe what is written to the
standard output is sent back to the client (if it is written after
correct headers).
Presumably, output on the standard error stream is written to Apacheʼs
error log. From within Emacs, you can write to standard error using [1]:
#+begin_src emacs-lisp
(print "This is the output" #'external-debugging-output)
#+end_src
Alternatively, you may want to look into other ways of logging. For
example you could:
1. send messages to logging daemons (like journald or syslog) connecting
to their sockets directly and sending them messages formatted according
to their protocols [2][3][4],
2. use a command line tool like “logger” by wrapping the Emacs Lisp
script:
#+NAME: posix-logger-wrapper
#+begin_src sh
{
./emacs-script 2>&1 1>&3 3>&- \
| logger -t "EMACSCGI" >/dev/null 2>&1 3>&-
} </dev/null 3>&1
#+end_src
#+NAME: bash-logger-wrapper
#+begin_src sh
# Using bashʼs process substitution:
./emacs-script > >(logger -t "EMACSCGI" >/dev/null 2>&1) </dev/null
#+end_src
3. run a command line tool like “logger” directly from within Emacs:
#+NAME: logger-within-emacs
#+begin_src emacs-lisp
(setq my/logger (start-process "logger" nil
"logger"
(format "--id=%s" (emacs-pid))
"-t" "EMACSCGI"
"--prio-prefix"))
;; <134> corresponds to facility “local0” with severity “info”.
;; See description of command line switch “--prio-prefix”.
(process-send-string my/logger "<134>Hello World.\n")
#+end_src emacs-lisp
4. write a log file with Emacs (‘append-to-file’, ‘write-file’,
‘write-region’).
Footnotes:
[1] (info "(elisp) Output Streams")
[2] Syslog Protocol: <https://datatracker.ietf.org/doc/rfc5424/>
[3] BSD Syslog Protocol: <https://tools.ietf.org/html/rfc3164>
[4] Journald Protocol: <https://systemd.io/JOURNAL_NATIVE_PROTOCOL/>
--
Felix Dietrich
prev parent reply other threads:[~2022-10-03 15:33 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-28 13:36 Apache2 error messages Jean Louis
2022-10-03 15:33 ` Felix Dietrich [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=871qro6hx3.fsf@sperrhaken.name \
--to=felix.dietrich@sperrhaken.name \
--cc=bugs@gnu.support \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).