Skip to content

๐Ÿ“Š๐Ÿš€Manage and store API logs efficiently with this Java Spring service. Automatically create daily log files in a standardized format and schedule uploads to Azure Blob Storage. Keep your API logs organized, accessible, and secure.

Notifications You must be signed in to change notification settings

Deshan555/ApiLog-Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

12 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Java Spring-Boot Service for Managing API Logs ๐Ÿ“

This README provides an overview of a Java Spring service for managing API logs. This service is designed to create a single log file for each day and schedule a cron job to upload that log file to Azure Blob Storage after 24 hours. You can configure the service using the application.yml file and adjust the scheduling interval in the SchaduleTask.java class. ๐Ÿ•’

Table of Contents ๐Ÿ“š


Prerequisites โš™๏ธ

Before setting up and running the service, make sure you have the following prerequisites:

  • Java Development Kit (JDK) installed (version 8 or higher).
  • Maven installed to build the project.
  • Azure Blob Storage account with a container.
  • Azure Storage Connection String.

Configuration ๐Ÿ› ๏ธ

You can configure the service by editing the application.yml file. Replace <YOUR_CONTAINER_NAME> and <YOUR_CONNECTION_STRING> with your Azure Blob Storage container name and connection string, respectively. ๐Ÿงฉ

azure:
  storage:
    container:
      name: <YOUR_CONTAINER_NAME>
    connection:
      string: <YOUR_CONNECTION_STRING>

Logging Format ๐Ÿ“‹

The log files generated by this service will have the following format:

[Date Time] [Client IP] [Client Port] [Server IP] [Server Port] [Protocol] [Method] [URL] [Protocol] [Server IP] [Server Port] [Status Code] [Status Message]

For example:

2023-10-07 21:35:29 127.0.0.1 4035 127.0.0.1 8080 HTTP/1.1 GET /log HTTP/1.1 127.0.0.1 400 log file upload Failed

Running the Service โ–ถ๏ธ

  1. Clone this repository to your local machine. ๐Ÿงฌ
git clone https://github.com/your/repository.git
cd repository-directory
  1. Open the project in your preferred Java IDE. ๐Ÿš€

  2. Configure the application.yml file with your Azure Blob Storage information. ๐Ÿงพ

  3. In the SchaduleTask.java class, adjust the scheduling interval by changing the @Scheduled annotation's fixedRate value according to your desired schedule. ๐Ÿ“…

@Scheduled(fixedRate = 86400000) // Change this value to your desired interval in milliseconds (24 hours by default).
public void uploadLogFileToAzureStorage() {
    // ...
}
  1. Build the project using Maven. ๐Ÿ—๏ธ
mvn clean install
  1. Run the Spring Boot application. โ–ถ๏ธ
mvn spring-boot:run

The service will start, and it will create a new log file for each day in the specified format. After 24 hours, the cron job will trigger the upload of the log file to Azure Blob Storage.

You have successfully set up and configured the Java Spring service for managing API logs with Azure Blob Storage integration. ๐Ÿš€๐Ÿ“ฆ

About

๐Ÿ“Š๐Ÿš€Manage and store API logs efficiently with this Java Spring service. Automatically create daily log files in a standardized format and schedule uploads to Azure Blob Storage. Keep your API logs organized, accessible, and secure.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages