Forwarding logs with im_file om_file

Tags:

#1 leshqo

Hi there,

I have several hosts where lots of logs are generated. On every of this hosts logs are placed into one directory and have different names with *.log extension. My point is to use nxlog on that hosts to forward logs into one central storage but I have problem with populating files names. I would like that file source/first.log to be populated to destination/first.log. Similarly source/second.log -> destination/second.log etc. Below is my config file.

Moduledir %ROOT%\modules
CacheDir %ROOT%\data
Pidfile %ROOT%\data\nxlog.pid
SpoolDir %ROOT%\data
LogFile %ROOT%\data\nxlog.log

define LOG_SERVER \\\\192.168.199.10

<Extension _syslog>
    Module      xm_syslog
</Extension>

<Input app-logs>
    Module im_file
    File "d:\\Logs\\\\*.log"
    InputType LineBased    
    <Schedule>
        Every 30 sec
        Exec log_info("scheduled execution at " + now());
    </Schedule>    
    Exec $fileName = file_name();
</Input>

<Output out>    
    Module om_file
    CreateDir TRUE        
    File "%LOG_SERVER%\\Shared\\Logs\\" + $fileName
</Output>

<Route 1>
    Path        app-logs => out
</Route>

Logs are not populating and I have in nxlog logs something like that

2015-11-20 15:11:00 ERROR CreateDir is TRUE but couldn't create directory: \\192.168.199.10\Shared\Logs\d:\Logs\; The specified path is invalid.  

Will be gratefull for help with my issue.

 

#2 adm Nxlog ✓
#1 leshqo
Hi there, I have several hosts where lots of logs are generated. On every of this hosts logs are placed into one directory and have different names with *.log extension. My point is to use nxlog on that hosts to forward logs into one central storage but I have problem with populating files names. I would like that file source/first.log to be populated to destination/first.log. Similarly source/second.log -> destination/second.log etc. Below is my config file. Moduledir %ROOT%\modules CacheDir %ROOT%\data Pidfile %ROOT%\data\nxlog.pid SpoolDir %ROOT%\data LogFile %ROOT%\data\nxlog.log define LOG_SERVER \\\\192.168.199.10 <Extension _syslog> Module xm_syslog </Extension> <Input app-logs> Module im_file File "d:\\Logs\\\\*.log" InputType LineBased <Schedule> Every 30 sec Exec log_info("scheduled execution at " + now()); </Schedule> Exec $fileName = file_name(); </Input> <Output out> Module om_file CreateDir TRUE File "%LOG_SERVER%\\Shared\\Logs\\" + $fileName </Output> <Route 1> Path app-logs => out </Route> Logs are not populating and I have in nxlog logs something like that 2015-11-20 15:11:00 ERROR CreateDir is TRUE but couldn't create directory: \\192.168.199.10\Shared\Logs\d:\Logs\; The specified path is invalid. Will be gratefull for help with my issue.  

I believe this is what you want since file_name() returns the full path which is giving the errors.

Exec $fileName = file_basename(file_name());