Skip to content

Commit

Permalink
logback v1.2.0 (#13)
Browse files Browse the repository at this point in the history
* logback v1.2.0

Gradle changes to support latest gradle.
Code changes to support latest java and javabrake.

* added example

* Removed blank spaces and Updated readme
  • Loading branch information
sumitjoshi1989 authored Dec 20, 2022
1 parent 1d92c88 commit 91f0dc2
Show file tree
Hide file tree
Showing 23 changed files with 1,077 additions and 173 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
.gradle
.project
.settings/*
build
.ackrc
bin
**target
**.DS_Store
**.vscode
Main.java
/src/main/resources
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

[![Build Status](https://travis-ci.org/airbrake/logback.svg?branch=master)](https://travis-ci.org/airbrake/logback)

## Introduction

logback is a logging Middleware in Java for Airbrake.

## Installation

Gradle:

```gradle
compile 'io.airbrake:logback:0.1.1'
compile 'io.airbrake:logback:0.1.2'
```

Maven:
Expand All @@ -16,19 +20,20 @@ Maven:
<dependency>
<groupId>io.airbrake</groupId>
<artifactId>logback</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
</dependency>
```

Ivy:

```xml
<dependency org='io.airbrake' name='logback' rev='0.1.1'>
<dependency org='io.airbrake' name='logback' rev='0.1.2'>
<artifact name='logback' ext='pom'></artifact>
</dependency>
```

## Configuration
If you want to send the error logs to Airbrake, you need to have following lines in logback.xml. Add this file in the resources folder. This is the main file for logback configuration. and contains information about log levels, log appenders.

```xml
<configuration>
Expand All @@ -53,3 +58,48 @@ Ivy:
</root>
</configuration>
```
## Error Logging

```java
import org.slf4j.LoggerFactory;
import ch.qos.logback.classic.Logger;

Logger logger = ((ch.qos.logback.classic.Logger))LoggerFactory.getLogger("Name");

try {
do();
} catch (IOException e) {
logger.error(e.getMessage());
}
```

## Notifier release instrucitons

### A note on Java version
Make sure you build and release this notifier with open-jdk, one way to manage your local java version is using [asdf](https://asdf-vm.com). You can install this tool via homebrew:
```
brew install asdf
```
Then install open-jdk-'mention version here' and set it as JAVA home before running any of the `./gradlew` commands:
```
asdf plugin add java
asdf install java openjdk-'mention version here'
export JAVA_HOME=$HOME/.asdf/installs/java/openjdk-'mention version here'
```

### Building and Releasing

```shell
./gradlew build
```
Upload to Maven Central:

```shell
./gradlew publish
```

To release the deployment to maven central repository:
- http://central.sonatype.org/pages/releasing-the-deployment.html

Usefull links:
- https://search.maven.org/artifact/io.airbrake/logback
180 changes: 73 additions & 107 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ buildscript {
mavenCentral()
}
dependencies {
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.11.0"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0"
}
}

plugins {
id 'com.jfrog.bintray' version '1.7.3'
}
plugins {
id 'java'
id 'java-library'
id 'maven-publish'
id 'signing'
}

apply plugin: 'maven'
apply plugin: 'java-library'
apply plugin: 'io.codearte.nexus-staging'
apply plugin: 'io.codearte.nexus-staging'

group = 'io.airbrake'
version = '0.1.1'
version = '0.1.2'
sourceCompatibility = 1.8
targetCompatibility = 1.8


if (project.hasProperty('signing.keyId')) {
apply plugin: 'signing'
Expand All @@ -26,15 +30,18 @@ if (project.hasProperty('signing.keyId')) {
}

repositories {
jcenter()
mavenCentral()
}

dependencies {
compile 'io.airbrake:javabrake:0.1.6'
compile 'ch.qos.logback:logback-classic:1.2.3'
compile 'org.slf4j:slf4j-api:1.7.25'
implementation 'io.airbrake:javabrake:0.3.0'
implementation 'ch.qos.logback:logback-classic:1.3.5'
testImplementation 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

testImplementation 'junit:junit:4.12'
java{
withJavadocJar()
withSourcesJar()
}

test {
Expand All @@ -48,105 +55,64 @@ test {
}
}

bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
configurations = ['archives']
publish = true
override = true
pkg {
repo = 'maven'
name = project.name
userOrg = 'airbrake'
licenses = ['MIT']
vcsUrl = 'https://github.com/airbrake/logback.git'
version {
name = project.version
desc = 'logback integration for javabrake'
vcsTag = project.version
}
}
}

if (project.hasProperty('ossrhUsername')) {
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots") {
authentication(userName: ossrhUsername, password: ossrhPassword)
}

pom.project {
name project.name
packaging 'jar'
description 'Logback integration for javabrake'
url 'https://airbrake.io'

scm {
connection 'https://github.com/airbrake/logback.git'
developerConnection 'https://github.com/airbrake/logback.git'
url 'https://github.com/airbrake/logback'
}

licenses {
license {
name 'MIT License'
url 'https://opensource.org/licenses/MIT'
}
}
publishing {
publications{

mavenJava(MavenPublication){

group = 'io.airbrake'
artifactId = 'logback'
version = '0.1.2'
description = 'logback integration for javabrake'
from(components.java)


pom{
name = 'logback'
url = 'https://airbrake.io'
description = 'Logback integration for javabrake'
licenses {
license {
name = 'MIT License'
url = 'https://opensource.org/licenses/MIT'
}
}
developers {
developer {
id = 'sumitjoshi1989'
name = 'Sumit Joshi'
email = '[email protected]'
}
}
scm {
connection = 'scm:git:git:github.com/airbrake/logback.git'
developerConnection = 'scm:git:ssh://github.com/airbrake/logback.git'
url = 'https://github.com/airbrake/logback'
}

developers {
developer {
id 'vmihailenco'
name 'Vladimir Mihailenco'
email '[email protected]'
}
}
}
}
}
}
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = 'sources'
from sourceSets.main.allSource
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier = 'javadoc'
from javadoc.destinationDir
repositories{
maven{

name = 'OSSRH'
url = 'https://oss.sonatype.org/service/local/staging/deploy/maven2'
// url = 'https://oss.sonatype.org/content/repositories/snapshots'
credentials {
username = project.properties["ossrhUsername"]
password = project.properties["ossrhPassword"]
}

}
}

}

artifacts {
archives sourcesJar
archives javadocJar
signing {
sign publishing.publications.mavenJava
}

task createPom {
doLast {
pom {
project {
groupId project.group
artifactId project.name
version project.version

inceptionYear '2017'
licenses {
license {
name 'MIT License'
url 'http://www.opensource.org/licenses/mit-license.php'
distribution 'repo'
}
}
}
}.writeTo("pom.xml")
}
}
build.dependsOn createPom
javadoc{

}
33 changes: 33 additions & 0 deletions examples/springboot/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
Binary file not shown.
2 changes: 2 additions & 0 deletions examples/springboot/.mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
Loading

0 comments on commit 91f0dc2

Please sign in to comment.