Message Logging with Syslog not configurable - Can't use variables for configuration

Skip to the first comment for a solution.

Hi there,

I'm currently trying to configure a MessageLogging-Policy with Syslog. Without defining the logLevel and without the use of variables for host, port, protocol, ... it works fine.

There seems to be a bug with the logLevel though. Everytime I want to define it, regardless what logLevel-value I choose, I get deployment errors, stating logLevel is not a part of the policy's schema:

"Error Saving Revision X
Error occurred while validation of bean log-error.xml. Reason: - Schema validation failed. Cause : unexpected element (uri:"", local:"logLevel"). Expected elements are <{}FormatMessage>,<{}SSLInfo>,<{}Message>,<{}Port>,<{}Host>,<{}Protocol>. Line number : 13. Column number : 19. File name : log-error.xml."

Furthermore, I want to use different syslog-servers for different environments. So I created a KeyValueMap holding the syslog-configuration parameters (Host, port, etc.). Extracting the values and assigning them to variables works fine. When I want to use them in the MessageLogging-Policy, however, I get the following deployment error:

" Error Saving Revision X
Error occurred while validation of bean log-error.xml. Reason: - Schema validation failed. Cause : Not a number: {syslog.port}. Line number : 7. Column number : 35. File name : log-error.xml."

(Validation also fails for all other variables except host)

Here's my MessageLogging configuration:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<MessageLogging async="false" continueOnError="false" enabled="true" name="log-error">  
	<DisplayName>log-error</DisplayName>  
	<Syslog>  
		<logLevel>ERROR</logLevel>
		<Message>[XYZ tag="{organization.name}" tag="{apiproxy.name}" tag="{environment.name}"] APIGEE Error ...</Message>  
		<Host>{syslog.host}</Host>  
		<Port>{syslog.port}</Port>  
		<Protocol>{syslog.protocol}</Protocol>  
		<SSLInfo>  
			<Enabled>{syslog.use-ssl}</Enabled>  
		</SSLInfo>  
		<FormatMessage>{syslog.format-message}</FormatMessage>  
	</Syslog>
</MessageLogging>

Would be great if someone could help me with these issues.


Thank you and regards, Jan

Solved Solved
0 6 1,140
1 ACCEPTED SOLUTION

Hi.

Regarding

"Error Saving Revision X
Error occurred while validation of bean log-error.xml. Reason: - Schema validation failed. Cause : unexpected element (uri:"", local:"logLevel"). Expected elements are <{}FormatMessage>,<{}SSLInfo>,<{}Message>,<{}Port>,<{}Host>,<{}Protocol>. Line number : 13. Column number : 19. File name : log-error.xml."

The logLevel element is a child of MessageLogging, not a child of Syslog. Therefore you must use something like this:

<MessageLogging name="log-error">  
  <logLevel>ERROR</logLevel>
  <Syslog>  
    <Message>...</Message> 
    ...
  </Syslog>
</MessageLogging> 

It is not possible to have the logLevel be determined by a variable.

Regarding the setting of host and port via variables, we have that feature request in the backlog. ref: b/65739579 .

View solution in original post

6 REPLIES 6

For everyone who is experiencing similar issues: We found another answer to the problem. At first it is to be said, that host and port cannot be set by using variables. They have to be fixed values. This is also stated in the MessageLogging-Policy's documentation. Furthermore, the logLevel has to be set outside the Syslog-Configuration-Tags. So there is no bug.

Since host and port cannot be set by variables, we had to come up with another solution in order to only define the log-server-connection once per environment. So we set up a dedicated Logging-Proxy which, in its conditional flow, checks in which environment it is deployed. Then it calls a dedicated MessageLogging-Policy for the specific environment. Other Proxies simply call the LoggingProxy using a ServiceCallout-Policy. This seems to work pretty well.

Only drawback is, the LogLevel cannot be set using a variable as well. This is, however, not stated in the documentation.

Hi.

Regarding

"Error Saving Revision X
Error occurred while validation of bean log-error.xml. Reason: - Schema validation failed. Cause : unexpected element (uri:"", local:"logLevel"). Expected elements are <{}FormatMessage>,<{}SSLInfo>,<{}Message>,<{}Port>,<{}Host>,<{}Protocol>. Line number : 13. Column number : 19. File name : log-error.xml."

The logLevel element is a child of MessageLogging, not a child of Syslog. Therefore you must use something like this:

<MessageLogging name="log-error">  
  <logLevel>ERROR</logLevel>
  <Syslog>  
    <Message>...</Message> 
    ...
  </Syslog>
</MessageLogging> 

It is not possible to have the logLevel be determined by a variable.

Regarding the setting of host and port via variables, we have that feature request in the backlog. ref: b/65739579 .

@Dino Thank you for your reply! I posted our solution in the first comment to my question. Can the logLevel, if placed correctly outside Syslog-Tags of course :-), be set by a variable. I couldn't find any restrictions on that in the documentation but in our case, it seems it doesn't work. We don't get a compile error, but no message is sent to the syslog server when we try to set the logLevel by variable.

It is not possible to have the logLevel be determined by a variable.

Former Community Member
Not applicable

The message logging policy as per documentation is async operation, but calling a proxy will make it non-async and will add latency to my response. Being able to parameterize the Message Logging policy will be a big plus.

@Dino: Do you know the status of (or can we track) backlog. ref: b/65739579?

Hi Anshul. I just checked; the status of that ticket is as yet UNRESOLVED.

We have the change for this enhancement, but have not merged and released it.

To track it you can open a support case.