Skip to content

Commit

Permalink
[#9893] Change filename log4j2.xml→log4j2-agent.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
intr3p1d committed May 19, 2023
1 parent 97edea0 commit 23923f6
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 16 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion agent/src/main/resources/pinpoint-root.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - Modify `pinpoint.profiler.profiles.active=release` in $PINPOINT_AGENT_DIR/pinpoint-root.config
# Custom Profile
# - 1. Create a custom profile in $PINPOINT_HOME/profiles/MyProfile
#    - Add pinpoint.config & log4j2.xml
#    - Add pinpoint.config
# - 2. -Dpinpoint.profiler.profiles.active=MyProfile
# Support external property
# - -Dpinpoint.config=$MY_CONFIG_PATH/pinpoint.config
Expand Down
2 changes: 1 addition & 1 deletion agent/src/main/resources/profiles/local/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - Modify `pinpoint.profiler.profiles.active=release` in $PINPOINT_AGENT_DIR/pinpoint-root.config
# Custom Profile
# - 1. Create a custom profile in $PINPOINT_HOME/profiles/MyProfile
#    - Add pinpoint.config & log4j2.xml
#    - Add pinpoint.config
# - 2. -Dpinpoint.profiler.profiles.active=MyProfile
# Support external property
# - -Dpinpoint.config=$MY_CONFIG_PATH/pinpoint.config
Expand Down
2 changes: 1 addition & 1 deletion agent/src/main/resources/profiles/release/pinpoint.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# - Modify `pinpoint.profiler.profiles.active=release` in $PINPOINT_AGENT_DIR/pinpoint-root.config
# Custom Profile
# - 1. Create a custom profile in $PINPOINT_HOME/profiles/MyProfile
#    - Add pinpoint.config & log4j2.xml
#    - Add pinpoint.config
# - 2. -Dpinpoint.profiler.profiles.active=MyProfile
# Support external property
# - -Dpinpoint.config=$MY_CONFIG_PATH/pinpoint.config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private void saveAgentRootPath(Path agentRootPath, Properties properties) {
private void saveLogConfigLocation(String activeProfile, Properties properties) {
String log4jLocation = properties.getProperty(Profiles.LOG_CONFIG_LOCATION_KEY);
if (StringUtils.isEmpty(log4jLocation)) {
LogConfigResolver logConfigResolver = new ProfileLogConfigResolver(profilesPath, activeProfile);
LogConfigResolver logConfigResolver = new SimpleLogConfigResolver(agentRootPath);
log4jLocation = logConfigResolver.getLogPath().toString();

properties.put(Profiles.LOG_CONFIG_LOCATION_KEY, log4jLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
* 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
* 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 com.navercorp.pinpoint.bootstrap.config;

import java.nio.file.Path;
Expand All @@ -22,17 +21,16 @@
/**
* @author Woonduk Kang(emeroad)
*/
public class ProfileLogConfigResolver implements LogConfigResolver {
private final Path profilesPath;
private final String activeProfile;
public class SimpleLogConfigResolver implements LogConfigResolver{

private final Path agentDirPath;

public ProfileLogConfigResolver(Path profilesPath, String activeProfile) {
this.profilesPath = Objects.requireNonNull(profilesPath, "profilesPath");
this.activeProfile = Objects.requireNonNull(activeProfile, "activeProfile");
public SimpleLogConfigResolver(Path agentDirPath) {
this.agentDirPath = Objects.requireNonNull(agentDirPath, "agentDirPath");
}

@Override
public Path getLogPath() {
return this.profilesPath.resolve(activeProfile);
return this.agentDirPath;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private void saveLogConfigLocation(Properties properties) {
throw new RuntimeException("Failed to read " + Profiles.ACTIVE_PROFILE_KEY + " from systemProperty");
}

LogConfigResolver logConfigResolver = new ProfileLogConfigResolver(profilesPath, activeProfile);
LogConfigResolver logConfigResolver = new SimpleLogConfigResolver(agentRootPath);
final Path log4jLocation = logConfigResolver.getLogPath();

properties.put(Profiles.LOG_CONFIG_LOCATION_KEY, log4jLocation.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class Log4j2LoggingSystem implements LoggingSystem {
public static final String FACTORY_PROPERTY_NAME = "log4j2.loggerContextFactory";
public static final String NOLOOKUPS = "log4j2.formatMsgNoLookups";

private static final String[] LOOKUP = {"log4j2-test.xml", "log4j2.xml", "log4j2.properties", "../../log4j2.xml"};
private static final String[] LOOKUP = {"log4j2-test.xml", "log4j2-agent.xml", "log4j2.properties"};

private LoggerContext loggerContext;
private final Path profilePath;
Expand Down Expand Up @@ -132,7 +132,7 @@ public void stop() {
this.binder.shutdown();
if (loggerContext instanceof LifeCycle) {
logger.info("{} loggerContext stop", this.getClass().getSimpleName());
((LifeCycle)loggerContext).stop();
((LifeCycle) loggerContext).stop();
}
}

Expand Down

0 comments on commit 23923f6

Please # to comment.