function 'create_var()' does not exist or takes different arguments


#1 Joao Alhinho (Last updated )

I'm trying to to save syslog and saving logs with a specific hostname based on the IP address. I'm using a if statement and a vaiable to define the file path I want to use. unfortunately I'm getting the folloging error message: nxlog.conf:32; couldn't parse statement at line 36, character 9 in C:\Program Files\nxlog\conf\nxlog.conf; function 'create_var()' does not exist or takes different arguments. 

My conf file is below. Any hint? 

 

define ROOT C:\Program Files\nxlog
Moduledir %ROOT%\modules
CacheDir C:\syslog
Pidfile C:\syslog\nxlog.pid
SpoolDir C:\syslog
LogFile C:\syslog\nxlog.log

<Extension exec> Module xm_exec </Extension>

<Extension syslog> Module xm_syslog </Extension>

<Input syslog514udp> Module im_udp Port 514 Host 0.0.0.0 </Input>

<Input syslog514tcp> Module im_tcp Port 514 Host 0.0.0.0 </Input>

<Output consolefile> Module om_file

#defining log path based on hostname
&lt;Exec&gt;
    if $MessageSourceAddress == "10.1.62.61"
    {   
        create_var('logPath', 'MySBC/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + '.log')
    }
    else
    {
        create_var('logPath', $MessageSourceAddress+'/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + '.log')
    }
&lt;/Exec&gt;

File      get_var('logPath')

# Addiere Zeitstempel an den Event
Exec        $raw_event = now() + " " + $raw_event;
&lt;Exec&gt;
	if consolefile-&gt;file_size() &gt;= 100M
	{	
		$newfile = $MessageSourceAddress+"/Syslog-"+ strftime(now(),"%Y-%m-%d-%H-%M") + ".log";
		consolefile-&gt;rotate_to($newfile);
	}
&lt;/Exec&gt;
CreateDir   TRUE

</Output>

<Output cdrlogger> Module om_udp Host 127.0.0.1 Port 1514 </Output>

<Route udp> Priority 1 Path syslog514udp => consolefile, cdrlogger </Route>

<Route tcp> Priority 2 Path syslog514tcp => consolefile, cdrlogger </Route>

#2 NenadMDeactivated Nxlog ✓

Hello,

The arguments you are trying to pass to the create_var() procedure can not be accepted. 

I guess the following describes your use case:
create_var(string varname, datetime expiry);
Create a module variable with the specified name. The expiry specifies when the variable should be deleted automatically. 

So, in this case you definitely don't need  MySBC/Syslog-  and  .log  in  create_var('logPath', 'MySBC/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + '.log').

PS: I could be wrong though. I assume you are trying to set the expiration time and 'MySBC/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + ‘.log’ seems like you are trying to assign a file name….