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\
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 </Input>

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

<Output consolefile> Module om_file

#defining log path based on hostname
    if $MessageSourceAddress == ""
        create_var('logPath', 'MySBC/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + '.log')
        create_var('logPath', $MessageSourceAddress+'/Syslog-'+ strftime(now(), '%Y-%m-%d-%H') + '.log')

File      get_var('logPath')

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


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

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

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

#2 NenadM


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….