主页 > app >
有关如何使用Azure App Service Linux处理日志的建议(azure application)
25-05-02
1
本文将介绍有关如何使用AzureAppServiceLinux处理日志的建议的详细情况,特别是关于azureapplication的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解
本文将介绍有关如何使用Azure App Service Linux处理日志的建议 的详细情况,特别是关于azure application 的相关信息。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j、Android 之 Service 学习篇一:Service 启动方式之 startService、Android 之 Service 学习篇二:Service 启动方式之 boundService、android.app.Application与android.app.Service 的知识。
本文目录一览:
有关如何使用Azure App Service Linux处理日志的建议(azure application) 如何解决有关如何使用Azure App Service Linux处理日志的建议
因此,我在Azure App Service中运行了一些应用程序。最重要的是,我有一个运行大多数应用程序代码的可执行jar。它当前正在与Java 11堆栈一起作为应用程序服务运行-我已经使用Azure Devops部署了jar文件,Azure将在其java 11容器中运行该jar。
我目前遇到的问题是应用程序日志。我曾经能够在运行代码的ssh上运行vm并检查tomcat日志(在转到Azure应用程序服务之前)。我还在虚拟机上安装了ELK,尽管很多时候我只是更喜欢ssh和grep并直接从虚拟机查看日志。
现在我所能做的就是访问日志流。这将在日志出来时流式传输日志,但是如果我想从昨天开始搜索错误,则无法这样做。我已经联系了Microsoft支持人员,到目前为止还没有什么帮助。我尝试使用应用程序见解,但不确定如何使我更好地查看日志。
单击“应用程序日志”选项卡不允许我做太多事情-我认为它具有Windows应用程序的更多功能。
我理想地寻找的也许是一种挂载存储帐户并在其中写入日志的方法?或做一些简单的日志分析,使我能够查看前一天的日志或进行搜索。任何人都可以推荐他们在这种情况下会做什么?
谢谢
解决方法
是的,它和上面提到的doc一样简单。只需部署该jar,然后指向jvm args中的该代理即可。
如果您有任何问题,请告诉我。
ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j 如何解决ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j
我正在Rails上执行此应用程序,页面加载正常,但在控制台中显示:
Started GET "/vendor/assets/stylesheets/bootstrap.min.css" for ::1 at 2020-08-17 09:09:51 -0500
Started GET "/vendor/assets/javascripts/bootstrap.min.js" for ::1 at 2020-08-17 09:09:51 -0500
ActionController::RoutingError (No route matches [GET]
"/vendor/assets/stylesheets/bootstrap.min.css"):
ActionController::RoutingError (No route matches [GET]
"/vendor/assets/javascripts/bootstrap.min.js"):
在我的供应商文件夹中,我同时拥有文件夹,javascript和样式表,并分别位于各自的bootsrtrap.min中。 即使在application.html.erb中,我也有以下内容:
<link href="vendor/assets/stylesheets/bootstrap.min.css" rel="stylesheet">
<%= csrf_Meta_tags %>
<%= stylesheet_link_tag ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
<%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>
</head>
<body>
<!-- Navigation -->
<nav>
<div>
<ahref="#">Instagram Clone</a>
<buttontype="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span></span>
</button>
<divid="navbarResponsive">
<ul>
<li>
<ahref="#">Home
<span>(current)</span>
</a>
</li>
<li>
<ahref="#">About</a>
</li>
<li>
<ahref="#">Services</a>
</li>
<li>
<ahref="#">Contact</a>
</li>
</ul>
</div>
</div>
</nav>
<!-- Page Content -->
<div>
<div>
<div>
<%= yield %>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript -->
<!--<script src="vendor/jquery/jquery.slim.min.js"></script>-->
<script src="vendor/assets/javascripts/bootstrap.min.js"></script>
</body>
</html>
在js和CSS这两个应用程序文件中,我都放置了“ require bootsrtrap.min”,即使该错误仍然出现在控制台中。 会是什么?
解决方法
RoR不使用目录作为文件夹结构指示。因为有资产装载者。您应该将5s或更少的css导入application.css中,并将js导入application.js中。并使用自己的助手添加捆绑文件:
1。用纱安装靴子
yarn add bootstrap @popperjs/core jquery
或
npm i bootstrap @popperjs/core jquery
栏位不超过5
2。在Assets Pipeline中导入文件
app / assets / stylesheets / application.css:
//...
require bootstrap/dist/css/bootstrap.min
//...
但是,如果需要,我建议使用SCSS并仅导入所需的样式。
app / assets / javascript / application.js:
//...
//= require jquery
//= require @popperjs/core
//= require bootstrap/dist/js/bootstrap.min
//...
3。在布局中导入资产
app / views / layout / application.html.erb:
<head>
...
<%= stylesheet_link_tag ''application'',media: ''all'' %>
</head>
<body>
...
<%= javascript_include_tag ''application'' %>
</body>
使用webpack滚动6
2。在application.scss和application.js中导入Bootstrap
app / javascript / stylesheets / application.scss:
//...
import ''bootstrap''
//...
app / javascript / packs / application.js:
import ''jquery''
import ''popper.js''
import ''bootstrap''
import ''../stylesheets/application''
3。在布局中导入捆绑包
<head>
...
<%= stylesheet_pack_tag ''application'',media: ''all'',''data-turbolinks-track'': ''reload'' %>
<%= javascript_pack_tag ''application'',''data-turbolinks-track'': ''reload'' %>
</head>
之后,您应该可以在所有应用程序中使用引导程序!
,
[解决方案]因此,在我的HTML(application.html.erb)内部,我有两个对js和css文件的调用:
<script src="assets/javascripts/bootstrap.min.js"></script>
<%= javascript_include_tag ''application'',''data-turbolinks-track'': ''reload'' %>
<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">
<%= csrf_meta_tags %>
<%= stylesheet_link_tag ''application'',''data-turbolinks-track'':
''reload'' %>
正如您在上面看到的那样,在使用javascript的情况下,我有一个使用脚本的调用,而另一个使用了的调用,两者都造成了问题,所以您只需要评论一个,我就对该脚本进行评论对于我的java文件和CSS文件,一个。 像这样:
<!--<link href="assets/stylesheets/bootstrap.min.css" rel="stylesheet">-->
<!--<script src="assets/javascripts/bootstrap.min.js"></script>-->
对我来说,解决了这个问题,我真的尝试了所有事情,这就是解决方案哈哈。
Android 之 Service 学习篇一:Service 启动方式之 startService Service 概念及用途:
A service is an application component that can perform long-running operations in the background and does not provide a user interface。
通常 service 用来执行一些耗时操作,或者后台执行不提供用户交互界面的操作,例如:下载、播放音乐。
Service 生命周期 :
Android Service 的生命周期并不像 Activity 那么复杂,它只继承了 onCreate (),onStart (),onDestroy () 三个方法,当我们第一次启动 Service 时,先后调用了 onCreate (),onStart () 这两个方法,当停止 Service 时,则执行 onDestroy () 方法,这里需要注意的是,如果 Service 已经启动了,当我们再次启动 Service 时,不会在执行 onCreate () 方法,而是直接执行 onStart () 方法,具体的可以看下面的实例。
Service 与 Activity 通信:
Service 后端的数据最终还是要呈现在前端 Activity 之上的,因为启动 Service 时,系统会重新开启一个新的进程,这就涉及到不同进程间通信的问题了 (AIDL) 这一节我不作过多描述,当我们想获取启动的 Service 实例时,我们可以用到 bindService 和 onBindService 方法,它们分别执行了 Service 中 IBinder () 和 onUnbind () 方法。
这里要提及一点:继承 service 的子类在重写 service 的方法中,除了一个 onStart () 方法之外,还有一个 onStartCommand () 方法,有关 onStartCommand () 方法稍微作点介绍:
Android 开发的过程中,每次调用 startService (Intent) 的时候,都会调用该 Service 对象的 onStartCommand (Intent,int,int) 方法,然后在 onStartCommand 方法中做一些处理。然后我们注意到这个函数有一个 int 的返回值,这篇文章就是简单地讲讲 int 返回值的作用。
从 Android 官方文档中,我们知道 onStartCommand 有 4 种返回值:
START _STICKY:如果 service 进程被 kill 掉,保留 service 的状态为开始状态,但不保留递送的 intent 对象。随后系统会尝试重新创建 service,由于服务状态为开始状态,所以创建服务后一定会调用 onStartCommand (Intent,int,int) 方法。如果在此期间没有任何启动命令被传递到 service,那么参数 Intent 将为 null。
START _NOT_STICKY:“非粘性的”。使用这个返回值时,如果在执行完 onStartCommand 后,服务被异常 kill 掉,系统将会把它置为 started 状态,系统不会自动重启该服务,直到 startService (Intent intent) 方法再次被调用;。
START _REDELIVER_INTENT:重传 Intent。使用这个返回值时,如果在执行完 onStartCommand 后,服务被异常 kill 掉,系统会自动重启该服务,并将 Intent 的值传入。
START _STICKY_COMPATIBILITY:
START _STICKY 的兼容版本,但不保证服务被 kill 后一定能重启。
有了 Service 类我们如何启动他呢,有两种方法:
• Context.startService() • Context.bindService()
1. 在同一个应用任何地方调用 startService () 方法就能启动 Service 了,然后系统会回调 Service 类的 onCreate () 以及 onStart () 方法。这样启动的 Service 会一直运行在后台,直到 Context.stopService () 或者 selfStop () 方法被调用。另外如果一个 Service 已经被启动,其他代码再试图调用 startService () 方法,是不会执行 onCreate () 的,但会重新执行一次 onStart () 。
2. 另外一种 bindService () 方法的意思是,把这个 Service 和调用 Service 的客户类绑起来,如果调用这个客户类被销毁,Service 也会被销毁。用这个方法的一个好处是,bindService () 方法执行后 Service 会回调上边提到的 onBind () 方发,你可以从这里返回一个实现了 IBind 接口的类,在客户端操作这个类就能和这个服务通信了,比如得到 Service 运行的状态或其他操作。如果 Service 还没有运行,使用这个方法启动 Service 就会 onCreate () 方法而不会调用 onStart ()。
区别概况为:
startService () 的调用者与服务没有联系,即使调用者退出了,服务仍然运行,而 bindService () 的调用者与服务绑在一起,调用者一旦退出了,服务也随即终止掉。
这里用一个实例 (使用
startService () 方法来启动 ) 来讲解一下 service 的声明周期和使用方法:
首先编写一个类继承 Service 这个基类,重写里面的方法,然后在 Activity 中调用
startService () 和 stopService () 来启动和停止服务。
运行界面:
工程目录结构:
ExampleService.java
package com.service.activity;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
public class ExampleService extends Service {
private static final String TAG = "ExampleService" ;
@Override
public void onCreate () {
Log.i(TAG, "ExampleService-onCreate" );
super .onCreate();
}
@Override
public void onStart (Intent intent, int startId) {
Log.i(TAG, "ExampleService-onStart" );
super .onStart(intent, startId);
}
@Override
public int onStartCommand (Intent intent, int flags, int startId) {
//执行文件的下载或者播放等操作
Log.i(TAG, "ExampleService-onStartCommand" );
/*
* 这里返回状态有三个值,分别是:
* 1、START_STICKY:当服务进程在运行时被杀死,系统将会把它置为started状态,但是不保存其传递的Intent对象,之后,系统会尝试重新创建服务;
* 2、START_NOT_STICKY:当服务进程在运行时被杀死,并且没有新的Intent对象传递过来的话,系统将会把它置为started状态,
* 但是系统不会重新创建服务,直到startService(Intent intent)方法再次被调用;
* 3、START_REDELIVER_INTENT:当服务进程在运行时被杀死,它将会在隔一段时间后自动创建,并且最后一个传递的Intent对象将会再次传递过来。
*/
return super .onStartCommand(intent, flags, startId);
}
@Override
public IBinder onBind (Intent intent) {
Log.i(TAG, "ExampleService-onBind" );
return null ;
}
@Override
public void onDestroy () {
Log.i(TAG, "ExampleService-onDestroy" );
super .onDestroy();
}
}
MainActivity.java
package com.service.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity implements OnClickListener {
private static final String TAG = "MainActivity" ; //日志输出标志
private Button btnStartService;
private Button btnStopService;
@Override
public void onCreate (Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.main);
btnStartService = (Button)findViewById(R.id.btnStartService);
btnStopService = (Button)findViewById(R.id.btnStopService);
btnStartService.setOnClickListener(this );
btnStopService.setOnClickListener(this );
}
//点击事件处理监听器
@Override
public void onClick (View v) {
Intent intent = new Intent(MainActivity.this ,ExampleService.class ) ;
switch (v.getId()){
case R.id.btnStartService:
startService(intent);
break ;
case R.id.btnStopService:
stopService(intent);
break ;
default :
break ;
}
}
}
最后在 AndroidManifest.xml 中对 service 进行声明,它跟 Activity 同一级,都写在 Application 标签里面:
<service android:name=".ExampleService"/>
创建完运行
在运行点击 "启动 service" 之后 (第一次启动 service),我们可以查看 LogCat 控制台输出的日志如下:
这个时候我们点击 "返回",Activity 被干掉了,但是我们的服务仍然在运行,可以查看 Setting-->Application-->Running Service, 截图如下:
然后回到我们的 Activity,再次点击启动 Service,控制台输出日志如下:
onCreate () 方法没有被调用,说明它并没有重新被创建。
然后我们点击停止 Service,输出日志如下:
Android 之 Service 学习篇二:Service 启动方式之 boundService 上一篇中介绍了 Service 的第一种方式,startService,这一篇来讲解一下另一张方式 bindService。
当创建一个能提供绑定功能的服务时,我们必须提供一个 IBinder 对象,客户端能使用这个对象与服务进行交换。在 Android 中有三种定义方式:
1、扩展 Binder 类 (条件:服务和应用在同一个进程当中,是最常见的情况)
2、使用 Messager
3、使用 AIDL (Android Interface Defination Language)
Bound Services
A bound service is the server in a client-server interface. A bound service allows components (such as activities) to bind to the service, send requests, receive responses, and even perform interprocess communication (IPC). A bound service typically lives only while it serves another application component and does not run in the background indefinitely.
这里以扩展 Binder 类为例讲解如何创建 Bound Services.
Binder extends
Object
implements
IBinder
java.lang.Object
↳
android.os.Binder
很明显,Binder 实现了 IBinder 这接口。
通过扩展 Binder 类创建 Bound Service 的步骤如下:
a、在 Service 类中,创建一个 Binder 实例,包含客户端能调用的公共方法,返回当前服务对象;
b、在 onBind () 方法中返回 Binder 实例;
c、在客户端,从 onServiceConnected 方法中获得 Binder 实例。
工程目录结构:
运行界面:
源代码:
MainActivity.java:
package com.service.activity;
import com.service.activity.BinderService.MyBinder;
import android.app.Activity;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class MainActivity extends Activity {
private Button btnStartService;
private Button btnstopService;
private boolean isConnected = false ;
@Override
public void onCreate (Bundle savedInstanceState) {
super .onCreate(savedInstanceState);
setContentView(R.layout.main);
btnStartService = (Button)findViewById(R.id.btnStartService);
btnStartService.setOnClickListener(listener);
btnstopService = (Button)findViewById(R.id.btnStopService);
btnstopService.setOnClickListener(listener);
}
private OnClickListener listener = new OnClickListener() {
@Override
public void onClick (View v) {
switch (v.getId()) {
case R.id.btnStartService:
funBindService();
break ;
case R.id.btnStopService:
funUnBindService();
break ;
default :
break ;
}
}
private void funBindService () {
Intent intent = new Intent(MainActivity.this , BinderService.class ) ;
bindService(intent, conn, Context.BIND_AUTO_CREATE);
}
private void funUnBindService () {
if (isConnected == true ){
unbindService(conn);
}
}
};
private ServiceConnection conn = new ServiceConnection() {
@Override
public void onServiceDisconnected (ComponentName name) {
isConnected = false ;
}
//与Service连接时被回调
@Override
public void onServiceConnected (ComponentName name, IBinder iBinder) {
MyBinder myBinder = (MyBinder)iBinder;
BinderService service = myBinder.getService();
service.MyMethod();
isConnected = true ;
}
};
}
BinderService.java
package com.service.activity;
import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.util.Log;
public class BinderService extends Service {
private static final String TAG = "BinderService" ;
private MyBinder myBinder = new MyBinder();
//内部类,扩展自Binder类
public class MyBinder extends Binder {
public BinderService getService () {
return BinderService.this ;
}
}
//复写onBind方法,并且返回IBinder的实现类
@Override
public IBinder onBind (Intent intent) {
Log.i(TAG, "onBind" );
return myBinder;
}
public void MyMethod () {
Log.i(TAG, "MyMethod" );
}
@Override
public boolean onUnbind (Intent intent) {
Log.i(TAG, "onUnbind" );
return super .onUnbind(intent);
}
@Override
public void onDestroy () {
Log.i(TAG, "onDestroy" );
super .onDestroy();
}
}
main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android ="http://schemas.android.com/apk/res/android"
android:layout_width ="fill_parent"
android:layout_height ="fill_parent"
android:orientation ="vertical" >
<Button
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="启动service"
android:id ="@+id/btnStartService" />
<Button
android:layout_width ="wrap_content"
android:layout_height ="wrap_content"
android:text ="停止service"
android:id ="@+id/btnStopService" />
</LinearLayout >
点击启动 service, 日志输出信息:
点击停止 service, 日志输出信息:
android.app.Application与android.app.Service 如何解决android.app.Application与android.app.Service | 我正在编写一个使用location.LocationManager和LocationListener接收GPS位置更新的android应用程序。该应用程序更新MapActivity上的位置,并将协同对象发送到静态Web服务。即使用户看不到MapActivity,Web服务也需要接收位置更新。 目前,我正在执行app.Application中的所有操作(UI除外),因为即使MapActivity不可见,它仍保持活动状态。但是,我阅读的所有文档都建议使用app.Application来存储状态,而不是执行更多的任务。我曾尝试使用app.Service,但似乎过于复杂(生命周期,绑定,解除绑定),并且存在许多内存泄漏问题。我无法找到任何明确禁止从app.Application执行此类任务的文章或文档,因此我想知道这种方法是否有问题? 编辑:感谢您的答复,看起来我将不得不花更多的时间来弄清楚app.Service
解决方法
您可能应该选择一项服务。我认为应用程序的生命周期绑定到当前正在运行的任何组件。我猜想,如果进程监视器没有运行任何应用程序或服务或其他任何东西,则在其他地方需要资源时,进程监视器可以随意销毁您的应用程序。您可能会发现您的代码有时可以工作,但会遇到意想不到的崩溃。 通常最好使用Android为不同组件指定的模型 , 通常,我认为使用Application是可以的:我已经广泛使用了它。我要说的主要问题是,唯一的生命周期回调是
onCreate
:使用
Service
,您至少可以选择使用
onDestroy
回调完全关闭它。 我承认,生命周期可能对ѭ1有点混乱。如果Application对象为您工作,那么我不会因为它而失眠。
关于有关如何使用Azure App Service Linux处理日志的建议 和azure application 的介绍现已完结,谢谢您的耐心阅读,如果想了解更多关于ActionController :: RoutingError没有路由与[GET]“ / vendor / assets / stylesheets / bootstrap.min.css”匹配 app / assets / stylesheets / application.css: app / assets / javascript / application.js: app / views / layout / application.html.erb: app / j、Android 之 Service 学习篇一:Service 启动方式之 startService、Android 之 Service 学习篇二:Service 启动方式之 boundService、android.app.Application与android.app.Service 的相关知识,请在本站寻找。