Is there any way to log into vLog module?

I want to keep some system logs in my Java custom code. There is a vLog module available in the Vahana. Is there any possibility of using that and if yes, how can I do that?

@Vikas_Dhillon @naveen.gupta @shivang.garg @Mayank

If we are using decimal-spring-boot-starter(boilerplate) library then its a inbuilt functionality to log into Vlogs.

Otherwise we can add logs-management library:

	 <dependency>
            <groupId>decimal</groupId>
            <artifactId>logs-management</artifactId>
            <version>2.9</version>
        </dependency>

Below properties required:

Add Kafka Properties to the application.properties:
spring.kafka.producer.bootstrap-servers = IP:PORT
spring.kafka.producer.key-serializer = org.apache.kafka.common.serialization.StringSerializer
spring.kafka.producer.value-serializer = decimal.logs.serializer.CustomSerializer
spring.kafka.producer.properties.message.max.bytes = 100000000
spring.kafka.producer.properties.max.request.size = 100000000

#
print.logs.on.console=
spring.main.allow-circular-references=true
Add Component Scan to the Main Class:
@ComponentScan(basePackages = { "decimal.logs.kafka"," decimal.logs.connector"}) // Add your JAR package as well

Call below method to send logs to vLogs:

        this.logsConnector.audit(auditPayload);
        this.logsConnector.error(errorPayload);
        this.logsConnector.endpoint(payload);


1 Like

How to Use vLogs in Custom Java APP

Thanks Naveen,

I know I am but demanding right now but historically Google docs are notorious and people face access issue to doc not found issue every now and then.

I would be great if you could copy paste the doc right here.

Here the Configuration Java class

Configuration File:
@Configuration
public class LogsManagementConfiguration {


    @Value("${isHttpTracingEnabled}")
    boolean isHttpTracingEnabled;

    @Bean
    @RequestScope
    public AuditPayload auditPayload() {
        return new AuditPayload();
    }

    @Bean
    @RequestScope
    public LogEntry logEntry() {
        return new LogEntry();
    }

    @Bean
    @RequestScope
    public Payload payload() {
        return new Payload();
    }
    @Bean
    @RequestScope
    public ErrorPayload errorPayload() {
        return new ErrorPayload();
    }
    @Bean
    public IdentifierFilter identifierFilter(){
        RequestIdentifierMapper requestIdentifierMapper = new RequestIdentifierMapper();
        requestIdentifierMapper.mapAppIdWithHeaderKey(Constants.ESB_HEADER_APP_ID);
        requestIdentifierMapper.mapOrgIdWithHeaderKey(Constants.ESB_HEADER_ORG_ID);
        requestIdentifierMapper.mapArnWithHeaderKey(Constants.ESB_HEADER_SERVICENAME);
        requestIdentifierMapper.mapTraceIdWithHeaderKey(Constants.ESB_HEADER_REQUEST_ID);
        requestIdentifierMapper.mapLogOrgIdWithHeaderKey(LogsIdentifier.logorgid.name());
        requestIdentifierMapper.mapLogAppIdWithHeaderKey(LogsIdentifier.logappid.name());
        return new IdentifierFilter(requestIdentifierMapper, isHttpTracingEnabled);
    }

        @Bean
        public AuditTraceFilter auditTraceFilter() {
            List<String> registeredUrls = new ArrayList<>();
            registeredUrls.add("authenticate");



            return new AuditTraceFilter("system-name", isHttpTracingEnabled, registeredUrls);
        }}


1 Like