WARNING: This server is unstable and will be retired in the next days. If you want to keep this forum available, please request immediately a migration on the Nabble Support forum. Forums that don't receive any migration request will be deleted forever.

 « Return to Thread: User name in access logs

Re: User name in access logs

by Christopher Faulet :: Rate this Message:

| View in Thread

Le 22/02/2012 00:45, Nicolas Thauvin a écrit :

> Hi to the list,
>
>   I would like to be able to dump an authenticated user name in the access  
> logs. The problem is: in our application, the user name is fetched from a  
> cookie hash using yaws_session_server. That means we cannot use the 'real'  
> authorization header, and arg_rewrite_mod acts too late for this purpose.
>
> I made a quick patch to use a custom module in order to fill the  
> 'authorization' structure from a cookie :
>
> https://github.com/nthauvin/yaws/commit/840ee7021b1b3fca751661637cad3e3b7bd7f697
>
> I am not really sure this is an appropriate way to do this. Any advice ?
>
Hi Nicolas,

If it is just about logging, a solution is to write your own logger.
This feature is not well documented but there are some information in
the manpage of yaws.conf.
Of course, in this module, you can call the default logger of Yaws.

Here is an example:


%% ===================================================================
-module(simplelogger).

-behaviour(yaws_logger).

-include_lib("yaws/include/yaws.hrl").
-include_lib("yaws/include/yaws_api.hrl").

%% API
-export([
         open_log/3,
         close_log/3,
         wrap_log/4,
         write_log/4
        ]).

open_log(ServerName, Type, Dir) ->
    yaws_log:open_log(ServerName, Type, Dir).

close_log(ServerName, Type, Ident) ->
    yaws_log:close_log(ServerName, Type, Ident).

wrap_log(ServerName, Type, Data, LogWrapSize) ->
    yaws_log:wrap_log(ServerName, Type, Data, LogWrapSize).

write_log(ServerName, Type, Ident, {Ip, Req, InH, OutH, Time}) ->
    Auth = {"foo", undefined, undefined},
    InH1 = InH#headers{authorization = Auth},
    yaws_log:write_log(ServerName, Type, Ident, {Ip, Req, InH1, OutH,
Time}).
%% ===================================================================

--
Christopher



------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Erlyaws-list mailing list
Erlyaws-list@...
https://lists.sourceforge.net/lists/listinfo/erlyaws-list

signature.asc (270 bytes) Download Attachment

 « Return to Thread: User name in access logs