Yes, this is currently based on 2.0-rc1.

On Wed, May 14, 2014 at 6:55 PM, Matt Sicker <[email protected]> wrote:

> Looks like you'll have to update it for the current API (which will be
> finalized with 2.0).
>
>
> On 14 May 2014 11:26, Mikael Ståldal <[email protected]>wrote:
>
>> I have made an Log4j 2 plugin to Liquibase (http://www.liquibase.org/).
>>
>> It seems like the Liquibase project don't want this kind of stuff in
>> their own project, they seems to encourage third-party plugins.
>>
>> But I would like this to be available as a public Maven dependency. So I
>> wonder if it's possible to include it as part of the Log4j project (as I
>> separate module I guess)?
>>
>> I have signed an Apache CLA, and I am willing to contribute the code.
>>
>> (The class have to be in the liquibase package in order for the Liquibase
>> plugin discovery to work.)
>>
>>
>> /*
>>  * Copyright (c) 2014, Appear Networks. All Rights Reserved.
>>  *
>>  * Licensed 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 liquibase.ext.logging.log4j2;
>>
>> import liquibase.changelog.ChangeSet;
>> import liquibase.changelog.DatabaseChangeLog;
>> import liquibase.logging.core.AbstractLogger;
>> import org.apache.logging.log4j.LogManager;
>> import org.apache.logging.log4j.Logger;
>>
>> /**
>>  * Logging to Log4j 2.x.
>>  */
>> public class Log4j2Logger extends AbstractLogger {
>>
>>     private Logger logger;
>>     private String changeLogName = null;
>>     private String changeSetName = null;
>>
>>     @Override
>>     public int getPriority() {
>>         return 5;
>>     }
>>
>>     @Override
>>     public void setName(String name) {
>>         logger = LogManager.getLogger(name);
>>     }
>>
>>     @Override
>>     public void setChangeLog(DatabaseChangeLog databaseChangeLog) {
>>         if (databaseChangeLog == null) {
>>             changeLogName = null;
>>         } else {
>>             changeLogName = databaseChangeLog.getFilePath();
>>         }
>>     }
>>
>>     @Override
>>     public void setChangeSet(ChangeSet changeSet) {
>>         changeSetName = (changeSet == null ? null :
>> changeSet.toString(false));
>>     }
>>
>>     @Override
>>     public void setLogLevel(String logLevel, String logFile) {
>>         setLogLevel(logLevel);
>>         // ignore logFile
>>     }
>>
>>     @Override
>>     public void severe(String message) {
>>         if (logger.isErrorEnabled()) {
>>             logger.error(formatMessage(message));
>>         }
>>     }
>>
>>     @Override
>>     public void severe(String message, Throwable e) {
>>         if (logger.isErrorEnabled()) {
>>             logger.error(formatMessage(message), e);
>>         }
>>     }
>>
>>     @Override
>>     public void warning(String message) {
>>         if (logger.isWarnEnabled()) {
>>             logger.warn(formatMessage(message));
>>         }
>>     }
>>
>>     @Override
>>     public void warning(String message, Throwable e) {
>>         if (logger.isWarnEnabled()) {
>>             logger.warn(formatMessage(message), e);
>>         }
>>     }
>>
>>     @Override
>>     public void info(String message) {
>>         if (logger.isInfoEnabled()) {
>>             logger.info(formatMessage(message));
>>         }
>>     }
>>
>>     @Override
>>     public void info(String message, Throwable e) {
>>         if (logger.isInfoEnabled()) {
>>             logger.info(formatMessage(message), e);
>>         }
>>     }
>>
>>     @Override
>>      public void debug(String message) {
>>         if (logger.isDebugEnabled()) {
>>             logger.debug(formatMessage(message));
>>         }
>>     }
>>
>>     @Override
>>     public void debug(String message, Throwable e) {
>>         if (logger.isDebugEnabled()) {
>>             logger.debug(formatMessage(message), e);
>>         }
>>     }
>>
>>      private String formatMessage(String message) {
>>         StringBuilder buffer = new StringBuilder();
>>         if (changeLogName != null) {
>>             buffer.append(changeLogName);
>>             buffer.append(": ");
>>         }
>>         if (changeSetName != null) {
>>             buffer.append(changeSetName.replace(changeLogName + "::",
>> ""));
>>             buffer.append(": ");
>>         }
>>         buffer.append(message);
>>         return buffer.toString();
>>     }
>> }
>>
>>
>>
>>
>>
>>
>> --
>> Mikael Ståldal
>> Chief Software Architect
>> *Appear*
>> Phone: +46 8 545 91 572
>> Email: [email protected]
>>
>
>
>
> --
> Matt Sicker <[email protected]>
>



-- 
Mikael Ståldal
Chief Software Architect
*Appear*
Phone: +46 8 545 91 572
Email: [email protected]

Reply via email to