Skip to content

Commit 1d3c7d6

Browse files
committed
LUTECE-2196 : Allow to reload the log4j configuration at runtime
1 parent 7addbba commit 1d3c7d6

File tree

5 files changed

+37
-0
lines changed

5 files changed

+37
-0
lines changed

src/java/fr/paris/lutece/portal/resources/system_messages.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ manage_caches.actionDisable=Turn off
6868
manage_caches.actionViewKeys=View config and keys
6969
manage_caches.buttonFlush=Flush all
7070
manage_caches.buttonViewKeys=View config and keys
71+
manage_caches.titleReloadLogsConfiguration=Log configuration loading
7172
manage_caches.titleReloadProperties=Properties loading
7273
manage_caches.labelReloadProperties=Reload properties files
7374
manage_caches.buttonReload=Reload

src/java/fr/paris/lutece/portal/resources/system_messages_fr.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ manage_caches.actionDisable=D\u00e9sactiver
6868
manage_caches.actionViewKeys=Visualiser les cl\u00e9s
6969
manage_caches.buttonFlush=Vider tous les caches
7070
manage_caches.buttonViewKeys=Visualiser les cl\u00e9s
71+
manage_caches.titleReloadLogsConfiguration=Rechargement de la configuration des logs
7172
manage_caches.titleReloadProperties=Rechargement des properties
7273
manage_caches.labelReloadProperties=Recharger les fichiers properties
7374
manage_caches.buttonReload=Recharger

src/java/fr/paris/lutece/portal/web/system/CacheJspBean.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import fr.paris.lutece.portal.service.i18n.I18nService;
4040
import fr.paris.lutece.portal.service.security.SecurityTokenService;
4141
import fr.paris.lutece.portal.service.template.AppTemplateService;
42+
import fr.paris.lutece.portal.service.util.AppLogService;
4243
import fr.paris.lutece.portal.service.util.AppPropertiesService;
4344
import fr.paris.lutece.portal.web.admin.AdminFeaturesPageJspBean;
4445
import fr.paris.lutece.util.html.HtmlTemplate;
@@ -70,6 +71,10 @@ public class CacheJspBean extends AdminFeaturesPageJspBean
7071
private static final String TEMPLATE_CACHE_INFOS = "admin/system/cache_infos.html";
7172
private static final String PARAMETER_ID_CACHE = "id_cache";
7273

74+
// Conf
75+
private static final String PATH_CONF = "/WEB-INF/conf/";
76+
private static final String FILE_PROPERTIES_CONFIG = "config.properties";
77+
7378
/**
7479
* Returns the page to manage caches
7580
*
@@ -138,6 +143,24 @@ public String doReloadProperties( HttpServletRequest request ) throws AccessDeni
138143
return JSP_MANAGE_CACHES;
139144
}
140145

146+
/**
147+
* Reload the logs configuration of the application
148+
*
149+
* @return The URL to display when the process is done.
150+
* @throws AccessDeniedException
151+
*/
152+
public String doReloadLogsConfiguration( HttpServletRequest request ) throws AccessDeniedException
153+
{
154+
if ( !SecurityTokenService.getInstance( ).validate( request, TEMPLATE_MANAGE_CACHES ) )
155+
{
156+
throw new AccessDeniedException( "Invalid security token" );
157+
}
158+
AppLogService.init( PATH_CONF, FILE_PROPERTIES_CONFIG );
159+
160+
return JSP_MANAGE_CACHES;
161+
}
162+
163+
141164
/**
142165
* Gets cache infos for all caches
143166
*

webapp/WEB-INF/templates/admin/system/manage_caches.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
<@button type='submit' buttonIcon='refresh' title='#i18n{portal.system.manage_caches.titleReloadProperties}' id='reload' size='' showTitleXs=false showTitleSm=false />
88
<@aButton href='jsp/admin/system/CacheInfos.jsp' buttonIcon='key' title='#i18n{portal.system.manage_caches.buttonViewKeys}' size='' showTitleXs=false showTitleSm=false />
99
</@tform>
10+
<@tform method='post' action='jsp/admin/system/DoReloadLogsConfiguration.jsp' class='pull-right spaced'>
11+
<input type="hidden" name="token" value="${token}">
12+
<@button type='submit' buttonIcon='refresh' title='#i18n{portal.system.manage_caches.titleReloadLogsConfiguration}' id='reloadLogsConf' size='' showTitleXs=false showTitleSm=false />
13+
</@tform>
1014
<@tform method='post' action='jsp/admin/system/DoResetCaches.jsp' class='pull-right spaced'>
1115
<input type="hidden" name="token" value="${token}">
1216
<@button type='submit' buttonIcon='trash' title='#i18n{portal.system.manage_caches.buttonFlush}' size='' color='btn-danger' showTitleXs=false showTitleSm=false />
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<%@ page errorPage="../ErrorPage.jsp" %>
2+
3+
<jsp:useBean id="cache" scope="session" class="fr.paris.lutece.portal.web.system.CacheJspBean" />
4+
5+
<%
6+
cache.init( request , cache.RIGHT_CACHE_MANAGEMENT );
7+
response.sendRedirect( cache.doReloadLogsConfiguration( request ) );
8+
%>

0 commit comments

Comments
 (0)