You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by "ruhulmus (via GitHub)" <gi...@apache.org> on 2023/02/19 02:07:27 UTC

[GitHub] [logging-log4j-samples] ruhulmus opened a new pull request, #6: Added Java Asynchronous logger with log4j2

ruhulmus opened a new pull request, #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6

   Added Java Asynchronous logger with log4j2


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1111191182


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>

Review Comment:
   Using `log4j-bom` in the dependency management section is the preferred way to fix a version.



##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>

Review Comment:
   ```suggestion
               <scope>runtime</scope>
   ```
   Adding `log4j-core` to the runtime scope stressed the fact that this is just one possible implementation of Log4j2 API.



##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>

Review Comment:
   ```suggestion
     <parent>
       <groupId>org.apache.logging.log4j.samples</groupId>
       <artifactId>log4j-samples</artifactId>
       <version>${revision}</version>
     </parent>
     <artifactId>log4j-samples-asynclogger</artifactId>
     <packaging>jar</packaging>
   ```



##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>

Review Comment:
   ```suggestion
           <disruptor.version>3.4.4</disruptor.version>
           <revision>2.19.1-SNAPSHOT</revision>
   ```



##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <!-- https://logging.apache.org/log4j/2.x/manual/async.html -->
+        <dependency>
+            <groupId>com.lmax</groupId>
+            <artifactId>disruptor</artifactId>
+            <version>${disruptor.version}</version>

Review Comment:
   Use the `runtime` version as above: your application does not use `disruptor` directly.



##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <!-- https://logging.apache.org/log4j/2.x/manual/async.html -->
+        <dependency>
+            <groupId>com.lmax</groupId>
+            <artifactId>disruptor</artifactId>
+            <version>${disruptor.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>

Review Comment:
   Why complicate the example with shading?
   
   If you are set on shading, add Eduard's [`maven-shaded-log4j-transformer`](https://github.com/edwgiz/maven-shaded-log4j-transformer).



##########
log4j-java-async-logger/src/main/java/org/apache/logging/log4j/async/Log4J2AsyncLogger.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.async;

Review Comment:
   I would use a package under `org.apache.logging.log4j.samples`, e.g. `org.apache.logging.log4j.samples.async`.



##########
log4j-java-async-logger/src/main/resources/log4j2.xml:
##########
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+            <PatternLayout>
+                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="3 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="5"/>
+        </RollingRandomAccessFile>
+
+    </Appenders>
+    <Loggers>
+
+        <!--  asynchronous loggers -->
+        <AsyncLogger name="org.apache.logging.log4j.async" level="debug" additivity="false">
+            <AppenderRef ref="LogToRollingRandomAccessFile"/>
+            <AppenderRef ref="LogToConsole"/>
+        </AsyncLogger>
+
+        <!-- synchronous loggers -->
+<!--        <Root level="error">-->
+<!--            <AppenderRef ref="LogToConsole"/>-->
+<!--        </Root>-->

Review Comment:
   Every configuration must have a root logger.
   
   If you uncomment these lines, you'll probably want to use additivity in the logger above.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118040426


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <!-- https://logging.apache.org/log4j/2.x/manual/async.html -->
+        <dependency>
+            <groupId>com.lmax</groupId>
+            <artifactId>disruptor</artifactId>
+            <version>${disruptor.version}</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.0</version>
+                <configuration>
+                    <source>${java.version}</source>
+                    <target>${java.version}</target>
+                </configuration>
+            </plugin>
+
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-shade-plugin</artifactId>

Review Comment:
   True, Actually I used it before in my example. So kept it as it is. btw I have updated with [`maven-shaded-log4j-transformer`](https://github.com/edwgiz/maven-shaded-log4j-transformer)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118040499


##########
log4j-java-async-logger/src/main/java/org/apache/logging/log4j/async/Log4J2AsyncLogger.java:
##########
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+package org.apache.logging.log4j.async;

Review Comment:
   Update.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Added Java Asynchronous logger with log4j2 (logging-log4j-samples)

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#issuecomment-1469458057

   > @ruhulmus,
   > 
   > I guess the native speakers do not have any further remark.
   > 
   > Thank You for your contribution, I am merging it.
   
   @ppkarwasz Thanks for you efforts :)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118039989


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>

Review Comment:
   Update with `log4j-bom`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118040693


##########
log4j-java-async-logger/src/main/resources/log4j2.xml:
##########
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+            <PatternLayout>
+                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="3 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="5"/>
+        </RollingRandomAccessFile>
+
+    </Appenders>
+    <Loggers>
+
+        <!--  asynchronous loggers -->
+        <AsyncLogger name="org.apache.logging.log4j.async" level="debug" additivity="false">
+            <AppenderRef ref="LogToRollingRandomAccessFile"/>
+            <AppenderRef ref="LogToConsole"/>
+        </AsyncLogger>
+
+        <!-- synchronous loggers -->
+<!--        <Root level="error">-->
+<!--            <AppenderRef ref="LogToConsole"/>-->
+<!--        </Root>-->

Review Comment:
   Yes. I have updated that sections too. Please check it. And kindly let me know if anything else :). 
   Thanks for your suggestions



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] jvz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "jvz (via GitHub)" <gi...@apache.org>.
jvz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1126788625


##########
log4j-java-async-logger/README.adoc:
##########
@@ -0,0 +1,227 @@
+## Java Asynchronous logger with log4j2
+
+We know Performance is critical for any applications and nobody wants the underlying logging framework to become a bottleneck.

Review Comment:
   ```suggestion
   We know performance is critical for any application and nobody wants the underlying logging framework to become a bottleneck.
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#issuecomment-1466164698

   @ruhulmus,
   
   I guess the native speakers do not have any further remark.
   
   Thank You for your contribution, I am merging it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1111194911


##########
log4j-java-async-logger/logs/app.log:
##########
@@ -0,0 +1,9 @@
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log

Review Comment:
   This file shouldn't end up in the repo.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1111191182


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>

Review Comment:
   Using `log4j-bom` in the dependency management section is the preferred way to manage a version.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz merged pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz merged PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118079705


##########
log4j-java-async-logger/README.adoc:
##########
@@ -0,0 +1,229 @@
+## Java Asynchronous logger with log4j2
+
+We know Performance is critical for any applications and nobody wants the underlying logging framework to become a bottleneck.
+We want lower logging latency and higher throughput. Also we want to increased the logging performance.
+
+In that case, The `asynchronous` logger in `log4J2` does this by decoupling the logging overhead from the thread executing your code.
+Async logger is designed to optimize this area by replacing the blocking queue with `disruptor` .
+`Disruptor` is a Lock-free inter-thread communication library. So by using this its provide higher throughput and lower latency in `Log4J2` logging.
+
+**Log4J2**  supports JSON,XML and YAML in addition to properties file configuration . Here I use XML file for the configuration.
+
+### Add log4j Dependancy :
+Add log4j Dependancy in  `pom.xml` file:
+
+```xml
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-bom</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-core</artifactId>
+    <scope>runtime</scope>
+</dependency>

Review Comment:
   ```suggestion
   <dependencyManagement>
     <dependencies>
       <dependency>
         <groupId>org.apache.logging.log4j</groupId>
         <artifactId>log4j-bom</artifactId>
         <version>2.20.0</version>
       </dependency>
     </dependencies>
   </dependencyManagement>
   <dependencies>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-api</artifactId>
     </dependency>
     <dependency>
       <groupId>org.apache.logging.log4j</groupId>
       <artifactId>log4j-core</artifactId>
       <scope>runtime</scope>
     </dependency>
     ...
   </dependencies>
   ```
   This should reflect what is in the POM.



##########
log4j-java-async-logger/README.adoc:
##########
@@ -0,0 +1,229 @@
+## Java Asynchronous logger with log4j2
+
+We know Performance is critical for any applications and nobody wants the underlying logging framework to become a bottleneck.
+We want lower logging latency and higher throughput. Also we want to increased the logging performance.
+
+In that case, The `asynchronous` logger in `log4J2` does this by decoupling the logging overhead from the thread executing your code.
+Async logger is designed to optimize this area by replacing the blocking queue with `disruptor` .
+`Disruptor` is a Lock-free inter-thread communication library. So by using this its provide higher throughput and lower latency in `Log4J2` logging.
+
+**Log4J2**  supports JSON,XML and YAML in addition to properties file configuration . Here I use XML file for the configuration.
+
+### Add log4j Dependancy :
+Add log4j Dependancy in  `pom.xml` file:
+
+```xml
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-bom</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-core</artifactId>
+    <scope>runtime</scope>
+</dependency>
+```
+
+### Add disruptor Dependancy :
+
+Add disruptor in `pom.xml` file
+
+```xml
+<dependency>
+    <groupId>com.lmax</groupId>
+    <artifactId>disruptor</artifactId>
+    <version>3.4.4</version>
+</dependency>
+```
+
+
+### Configure `log4j2.xml` file for Log4J 2 async logger :
+We will use XML to configure Log4J2 2 async logger.
+Now Create a `log4j2.xml` file in the project classpath.
+
+1. *Add basic configuration*
+
+Path : `src/resources/log4j2.xml`
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Logger>
+        <Root level="error">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+    </Loggers>
+</Configuration>
+```
+2. *Now add `RollingRandomAccessFile` Sections into `Appenders`  to configure the rolling log files*
+
+```xml
+ <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+    <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+    </PatternLayout>
+    <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="3 MB"/>
+    </Policies>
+    <DefaultRolloverStrategy max="5"/>
+</RollingRandomAccessFile>
+
+
+```
+3. *Now add `AsyncAppender` Appender into the `Loggers` sections. So after the configuraiton, `log4j2.xml` file should be look like :*
+
+```xml
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+            <PatternLayout>
+                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="3 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="5"/>
+        </RollingRandomAccessFile>
+
+    </Appenders>
+    <Loggers>
+
+        <!--  asynchronous loggers -->
+       <AsyncLogger  name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToRollingRandomAccessFile"/>
+        </AsyncLogger>
+        <Root level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+
+    </Loggers>
+</Configuration>
+```
+*We can change the status to `trace`, `debug`, `info`, `warn`,  and `fatal` to enable the internal Log4j events.*
+
+### Configure `Log4J2AsyncLogger.java` Class :
+Now create a logger class `Log4J2AsyncLogger.java` that uses the Log4J2 API to log the messages.
+
+```java
+package org.apache.logging.log4j.async;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4J2AsyncLogger {
+
+    private static final Logger logger = LogManager.getLogger(Log4J2AsyncLogger.class);
+
+    public static void main(String[] args) {
+
+        Log4J2AsyncLogger myLog = new Log4J2AsyncLogger();
+        myLog.getLog("Log4j2 Log");
+
+    }
+
+    private void getLog(String param){
+
+        logger.info("This is a info log");
+
+        // Previously, need to check the log level log to increase performance
+        if(logger.isDebugEnabled()){
+            logger.debug("This is debug log with param : " + param);
+        }
+
+        if(logger.isWarnEnabled()){
+            logger.info("This is warn log with param : " + param);
+        }
+
+        // In Java 8, No need to check the log level, we can do this
+        while (true) //for test rolling file
+            logger.debug("Hello print {}", () -> getValue());
+    }
+
+    static String getValue() {
+        return "Debug Log";
+    }
+}
+```
+
+### Configure `Log4J2AsyncLoggerException.java` Class :
+Create another logger class `Log4J2AsyncLoggerException.java` to create and check exceptions.
+
+```java
+package org.apache.logging.log4j.async;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4J2AsyncLoggerException {
+
+    private static final Logger logger = LogManager.getLogger(Log4J2AsyncLoggerException.class);
+
+    public static void main(String[] args) {
+
+        try {
+            System.out.println(getException());
+        } catch (IllegalArgumentException e) {
+            logger.error("{}", e);

Review Comment:
   ```suggestion
               logger.error("An error occurred.", e);
   ```
   
   Logging events have a text component and a throwable component. You should not pass throwables as text, because:
   
    * some information is lost in the conversion,
    * the user of the application might want to disable the printing of stack traces.



##########
log4j-java-async-logger/README.adoc:
##########
@@ -0,0 +1,229 @@
+## Java Asynchronous logger with log4j2
+
+We know Performance is critical for any applications and nobody wants the underlying logging framework to become a bottleneck.
+We want lower logging latency and higher throughput. Also we want to increased the logging performance.
+
+In that case, The `asynchronous` logger in `log4J2` does this by decoupling the logging overhead from the thread executing your code.
+Async logger is designed to optimize this area by replacing the blocking queue with `disruptor` .
+`Disruptor` is a Lock-free inter-thread communication library. So by using this its provide higher throughput and lower latency in `Log4J2` logging.
+
+**Log4J2**  supports JSON,XML and YAML in addition to properties file configuration . Here I use XML file for the configuration.
+
+### Add log4j Dependancy :
+Add log4j Dependancy in  `pom.xml` file:
+
+```xml
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-bom</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-core</artifactId>
+    <scope>runtime</scope>
+</dependency>
+```
+
+### Add disruptor Dependancy :
+
+Add disruptor in `pom.xml` file
+
+```xml
+<dependency>
+    <groupId>com.lmax</groupId>
+    <artifactId>disruptor</artifactId>
+    <version>3.4.4</version>
+</dependency>
+```
+
+
+### Configure `log4j2.xml` file for Log4J 2 async logger :
+We will use XML to configure Log4J2 2 async logger.
+Now Create a `log4j2.xml` file in the project classpath.
+
+1. *Add basic configuration*
+
+Path : `src/resources/log4j2.xml`
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Logger>
+        <Root level="error">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+    </Loggers>
+</Configuration>
+```
+2. *Now add `RollingRandomAccessFile` Sections into `Appenders`  to configure the rolling log files*
+
+```xml
+ <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+    <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+    </PatternLayout>
+    <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="3 MB"/>
+    </Policies>
+    <DefaultRolloverStrategy max="5"/>
+</RollingRandomAccessFile>
+
+
+```
+3. *Now add `AsyncAppender` Appender into the `Loggers` sections. So after the configuraiton, `log4j2.xml` file should be look like :*
+
+```xml
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+            <PatternLayout>
+                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="3 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="5"/>
+        </RollingRandomAccessFile>
+
+    </Appenders>
+    <Loggers>
+
+        <!--  asynchronous loggers -->
+       <AsyncLogger  name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToRollingRandomAccessFile"/>
+        </AsyncLogger>
+        <Root level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+
+    </Loggers>
+</Configuration>
+```
+*We can change the status to `trace`, `debug`, `info`, `warn`,  and `fatal` to enable the internal Log4j events.*
+
+### Configure `Log4J2AsyncLogger.java` Class :
+Now create a logger class `Log4J2AsyncLogger.java` that uses the Log4J2 API to log the messages.
+
+```java
+package org.apache.logging.log4j.async;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4J2AsyncLogger {
+
+    private static final Logger logger = LogManager.getLogger(Log4J2AsyncLogger.class);
+
+    public static void main(String[] args) {
+
+        Log4J2AsyncLogger myLog = new Log4J2AsyncLogger();
+        myLog.getLog("Log4j2 Log");
+
+    }
+
+    private void getLog(String param){
+
+        logger.info("This is a info log");
+
+        // Previously, need to check the log level log to increase performance
+        if(logger.isDebugEnabled()){
+            logger.debug("This is debug log with param : " + param);
+        }

Review Comment:
   ```suggestion
           logger.debug("This is debug log with param : {}", param);
   ```
   
   Do not wrap logging calls in `isDebugEnabled()`, just use parameter placeholders (do not use string concatenation).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118085428


##########
log4j-java-async-logger/README.adoc:
##########
@@ -0,0 +1,229 @@
+## Java Asynchronous logger with log4j2
+
+We know Performance is critical for any applications and nobody wants the underlying logging framework to become a bottleneck.
+We want lower logging latency and higher throughput. Also we want to increased the logging performance.
+
+In that case, The `asynchronous` logger in `log4J2` does this by decoupling the logging overhead from the thread executing your code.
+Async logger is designed to optimize this area by replacing the blocking queue with `disruptor` .
+`Disruptor` is a Lock-free inter-thread communication library. So by using this its provide higher throughput and lower latency in `Log4J2` logging.
+
+**Log4J2**  supports JSON,XML and YAML in addition to properties file configuration . Here I use XML file for the configuration.
+
+### Add log4j Dependancy :
+Add log4j Dependancy in  `pom.xml` file:
+
+```xml
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-bom</artifactId>
+</dependency>
+
+<dependency>
+    <groupId>org.apache.logging.log4j</groupId>
+    <artifactId>log4j-core</artifactId>
+    <scope>runtime</scope>
+</dependency>
+```
+
+### Add disruptor Dependancy :
+
+Add disruptor in `pom.xml` file
+
+```xml
+<dependency>
+    <groupId>com.lmax</groupId>
+    <artifactId>disruptor</artifactId>
+    <version>3.4.4</version>
+</dependency>
+```
+
+
+### Configure `log4j2.xml` file for Log4J 2 async logger :
+We will use XML to configure Log4J2 2 async logger.
+Now Create a `log4j2.xml` file in the project classpath.
+
+1. *Add basic configuration*
+
+Path : `src/resources/log4j2.xml`
+
+```xml
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Logger name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Logger>
+        <Root level="error">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+    </Loggers>
+</Configuration>
+```
+2. *Now add `RollingRandomAccessFile` Sections into `Appenders`  to configure the rolling log files*
+
+```xml
+ <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+    <PatternLayout>
+        <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+    </PatternLayout>
+    <Policies>
+        <TimeBasedTriggeringPolicy/>
+        <SizeBasedTriggeringPolicy size="3 MB"/>
+    </Policies>
+    <DefaultRolloverStrategy max="5"/>
+</RollingRandomAccessFile>
+
+
+```
+3. *Now add `AsyncAppender` Appender into the `Loggers` sections. So after the configuraiton, `log4j2.xml` file should be look like :*
+
+```xml
+<Configuration status="DEBUG">
+    <Appenders>
+        <Console name="LogToConsole" target="SYSTEM_OUT">
+            <PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n"/>
+        </Console>
+        <RollingRandomAccessFile name="LogToRollingRandomAccessFile" fileName="logs/app.log"
+                                 filePattern="logs/$${date:yyyy-MM}/app-%d{MM-dd-yyyy}-%i.log">
+            <PatternLayout>
+                <Pattern>%d %p %c{1.} [%t] %m%n</Pattern>
+            </PatternLayout>
+            <Policies>
+                <TimeBasedTriggeringPolicy/>
+                <SizeBasedTriggeringPolicy size="3 MB"/>
+            </Policies>
+            <DefaultRolloverStrategy max="5"/>
+        </RollingRandomAccessFile>
+
+    </Appenders>
+    <Loggers>
+
+        <!--  asynchronous loggers -->
+       <AsyncLogger  name="org.apache.logging.log4j.samples.async" level="debug">
+            <AppenderRef ref="LogToRollingRandomAccessFile"/>
+        </AsyncLogger>
+        <Root level="debug">
+            <AppenderRef ref="LogToConsole"/>
+        </Root>
+
+    </Loggers>
+</Configuration>
+```
+*We can change the status to `trace`, `debug`, `info`, `warn`,  and `fatal` to enable the internal Log4j events.*
+
+### Configure `Log4J2AsyncLogger.java` Class :
+Now create a logger class `Log4J2AsyncLogger.java` that uses the Log4J2 API to log the messages.
+
+```java
+package org.apache.logging.log4j.async;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4J2AsyncLogger {
+
+    private static final Logger logger = LogManager.getLogger(Log4J2AsyncLogger.class);
+
+    public static void main(String[] args) {
+
+        Log4J2AsyncLogger myLog = new Log4J2AsyncLogger();
+        myLog.getLog("Log4j2 Log");
+
+    }
+
+    private void getLog(String param){
+
+        logger.info("This is a info log");
+
+        // Previously, need to check the log level log to increase performance
+        if(logger.isDebugEnabled()){
+            logger.debug("This is debug log with param : " + param);
+        }
+
+        if(logger.isWarnEnabled()){
+            logger.info("This is warn log with param : " + param);
+        }
+
+        // In Java 8, No need to check the log level, we can do this
+        while (true) //for test rolling file
+            logger.debug("Hello print {}", () -> getValue());
+    }
+
+    static String getValue() {
+        return "Debug Log";
+    }
+}
+```
+
+### Configure `Log4J2AsyncLoggerException.java` Class :
+Create another logger class `Log4J2AsyncLoggerException.java` to create and check exceptions.
+
+```java
+package org.apache.logging.log4j.async;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+public class Log4J2AsyncLoggerException {
+
+    private static final Logger logger = LogManager.getLogger(Log4J2AsyncLoggerException.class);
+
+    public static void main(String[] args) {
+
+        try {
+            System.out.println(getException());
+        } catch (IllegalArgumentException e) {
+            logger.error("{}", e);

Review Comment:
   > ** [ppkarwasz](/ppkarwasz)**
   
   
   
   > Logging events have a text component and a throwable component. You should not pass throwables as text, because:
   > 
   > * some information is lost in the conversion,
   > * the user of the application might want to disable the printing of stack traces.
   
   You are Right. Thanks for the update :).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118040782


##########
log4j-java-async-logger/logs/app.log:
##########
@@ -0,0 +1,9 @@
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log
+2023-02-19 01:15:31,000 DEBUG o.a.l.l.a.Log4J2AsyncLogger [main] Hello print Debug Log

Review Comment:
   updated this sections too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1118040042


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <!-- https://logging.apache.org/log4j/2.x/manual/async.html -->
+        <dependency>
+            <groupId>com.lmax</groupId>
+            <artifactId>disruptor</artifactId>
+            <version>${disruptor.version}</version>

Review Comment:
   updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ppkarwasz commented on a diff in pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ppkarwasz (via GitHub)" <gi...@apache.org>.
ppkarwasz commented on code in PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#discussion_r1111191387


##########
log4j-java-async-logger/pom.xml:
##########
@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements. See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License. You may obtain a copy of the License at
+  ~
+  ~      http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
+         http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.log4j</groupId>
+    <artifactId>log4j2</artifactId>
+    <version>1.0.0</version>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <java.version>1.8</java.version>
+        <log4j.version>2.17.1</log4j.version>
+        <disruptor.version>3.4.4</disruptor.version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-api</artifactId>
+            <version>${log4j.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.logging.log4j</groupId>
+            <artifactId>log4j-core</artifactId>
+            <version>${log4j.version}</version>

Review Comment:
   ```suggestion
               <scope>runtime</scope>
   ```
   Adding `log4j-core` to the runtime scope stresses the fact that this is just one possible implementation of Log4j2 API.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [logging-log4j-samples] ruhulmus commented on pull request #6: Added Java Asynchronous logger with log4j2

Posted by "ruhulmus (via GitHub)" <gi...@apache.org>.
ruhulmus commented on PR #6:
URL: https://github.com/apache/logging-log4j-samples/pull/6#issuecomment-1455528636

   > This looks almost ready to me. I would just:
   > 
   > * rename the `log4j-java-async-logger` folder to `log4j-samples-asynclogger` for coherence,
   > * ask a native speaker to proofread `README.adoc`, @jvz @rgoers can you take a look at it?
   
   @ppkarwasz, Any update about the `README.adoc` review? Do we have any one who can review it? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org