Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

EmrD/java-logging-package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

7 Commits

Repository files navigation

Logging Library With Java

A simple Java logging library.

Features

  • DEBUG, INFO, WARN, ERROR levels
  • Writes logs to a file
  • Easy to use

Installation

Step 1: Download the JAR File

Download the logging.jar file from the Releases page.

Step 2: Add the JAR to Your Project

a. Using an IDE (Eclipse, IntelliJ, etc.)

  • Eclipse:

    1. Right-click on your project.
    2. Select Build Path > Add External Archives....
    3. Choose the downloaded logging.jar file and add it.
  • IntelliJ IDEA:

    1. Go to File > Project Structure > Modules > Dependencies.
    2. Click the + button and select JARs or directories.
    3. Select the logging.jar file and add it.
  • Visual Studio Code:

    1. Install Java extention from Marketplace.
    2. Open your project with Java extention.
    3. Go to your Project Settings > Libraries > Add Library > Select JAR file > Apply Settings.
    4. Restart your IDE.

b. Using Command Line

  1. Place the JAR File:

    Create a lib directory in your project and move logging.jar into it.

  2. Compile Your Project:

     javac -cp lib/logging.jar -d bin src/yourapp/*.java
     java -cp bin:lib/logging.jar yourapp.MainClass

Note: On Windows, use ; instead of : as the classpath separator:

 java -cp bin;lib/logging.jar yourapp.MainClass

Example usage

import com.emr.logging.Logger;
import com.emr.logging.LogLevel;
public class Example {
 public static void main(String[] args) {
 Logger logger = new Logger(LogLevel.INFO);
 logger.debug("This is a debug message.");
 logger.info("Application started.");
 logger.warn("This is a warning message.");
 logger.error("This is an error message.");
 logger.close(); 
 }
}

AltStyle によって変換されたページ (->オリジナル) /